JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 354 forks source link

Color and width problems for contour line plots in plotly #1218

Open biggsbiggsby opened 7 years ago

biggsbiggsby commented 7 years ago

Hi, I'm having some problems plotting contour line plots (fill=false) using the GR backend.

MWE:

using Plots; gr()
Plots.contour(collect(1:100)*collect(1:100)', fill=true, c=:turbid)
Plots.contour!(collect(1:100)*collect(1:100)', fill=false, c=:gray, linewidth=10)

This gives: image

This should first plot a filled contour using the turbid colorscale, then plot a line contour on top with the gray colorscale, with quite thick lines (w=10). Instead the colorscale is only applied to the plot when fill=true, otherwise the colorscale request is ignored, and the default is used. Additionally the line width command is always ignored on these plots. (The same behavior occurs when only a line plot is made; the combination plot here is just to contrast the working and aberrant behavior.)

Version info: GR 0.24.0 Plots 0.13.1 Julia 0.6.1

biggsbiggsby commented 7 years ago

It seems that there is another issue where levels attribute is also ignored when fill=true, but works when fill=false. It is always applied to the colorbar correctly though:

Plots.contour(collect(1:100)*collect(1:100)',fill=true,c=:turbid,levels=5) image

mkborregaard commented 7 years ago

This does appear to be a GR-related issue (@jheinen), though there are also bugs with the plotlyjs version (colorscale overlap and line widths) skaermbillede 2017-11-01 kl 10 43 12

The pyplot version appears to do what you expect: skaermbillede 2017-11-01 kl 10 53 23

mkborregaard commented 7 years ago

Also tagging @daschw who is an expert on the colorbar functionality :-)

daschw commented 7 years ago

Hm, for me the example code on GR looks like this on master: gr_contour_colors So the colors issue should be fixed on master. The contourf issue has already been reported in https://github.com/JuliaPlots/Plots.jl/issues/1024. As you can see, with GR a gray colourbar is shown, which somehow makes sense, because the gray contour is plotted later. Although I think that in this case the :turbid colorbar looks nicer.

daschw commented 7 years ago

the linewidth in GR should be fixed by https://github.com/JuliaPlots/Plots.jl/pull/1221

mkborregaard commented 7 years ago

It works for me on master now. Suddenly I doubt whether I remembered to check the GR version. Sweet fix, @daschw !

mkborregaard commented 7 years ago

Let me redefine the issue.

daschw commented 7 years ago

Thx, what's your opinion on the colorbar color @mkborregaard (GR vs PyPlot)?

mkborregaard commented 7 years ago

I think the plotly colorbar issue is a duplicate of #694

mkborregaard commented 7 years ago

In this case PyPlot looks best, but generally I'd say it makes sense to show the colorbar for the latest plotted series?

mkborregaard commented 7 years ago

There's also still this issue with GR:

It seems that there is another issue where levels attribute is also ignored when fill=true, but works when fill=false

This is turning into one of those intractable issues, where it's unclear how it can be closed and what backend it refers to...

daschw commented 7 years ago

In this case PyPlot looks best, but generally I'd say it makes sense to show the colorbar for the latest plotted series?

Agreed. So actually we should change the PyPlot behavior? The problem is: I can't think of a way to get the (nicer) PyPlot result with the current GR implementation in this current test example.

I think that the levels issue has something to do with the fact that GR.surface is used for contourf. I played around a little but I have no idea how to fix this. I think we need @jheinen's superpowers here.

mkborregaard commented 7 years ago

:pray:

jheinen commented 7 years ago

the level issue can only be fixed with a new contour fill routine - should be available with the next GR release ...

ccmejia commented 3 years ago

Dear all, I was wondering if could be possible to remove or hide the lines (at the colorbar) related to contours.
This is the code to create the attached figure:

p1 = heatmap(xof, yof, abs.(U0_vtx1_v0), colorbar_title = L"$ |U(x, y)| $"); contour!(xof, yof, abs.(ROF(0))./maximum(abs.(ROF(0))), c=:grays, levels = 0.0:0.15:1) p2 = heatmap(xof, yof, angle.(U0_vtx1_v0), colorbar_title = L"$ \psi(x, y) $"); contour!(xof, yof, abs.(ROF(0))./maximum(abs.(ROF(0))), c=:black, levels = 0.0:0.15:1) plot(p1, p2, layout = (1, 2), xlabel = L"x", ylabel = L"y", size = (700, 330), ratio = 1, linewidth = 0.5)

vtxS1.pdf

BeastyBlacksmith commented 3 years ago

@ccmejia your issue seems unrelated to this issue. Can you open a new issue for that and provide an example that can be run? Yours has some undefined variables.

jks-liu commented 2 years ago

Maybe same as #694 and #673

Maybe related to upstream issue of plotly/plotly.js#5098 and plotly/plotly.js#5099