Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
biggsbiggsby opened this issue Nov 1, 2017 · 17 comments
Open

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

biggsbiggsby opened this issue Nov 1, 2017 · 17 comments

Comments

@biggsbiggsby
Copy link
Contributor

biggsbiggsby commented Nov 1, 2017

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
Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

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

@daschw
Copy link
Member

daschw commented Nov 2, 2017

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 #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
Copy link
Member

daschw commented Nov 2, 2017

the linewidth in GR should be fixed by #1221

@mkborregaard
Copy link
Member

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

@mkborregaard
Copy link
Member

Let me redefine the issue.

@mkborregaard mkborregaard changed the title Color and width problems for contour line plots in GR Color and width problems for contour line plots in plotly Nov 2, 2017
@mkborregaard mkborregaard removed the GR label Nov 2, 2017
@daschw
Copy link
Member

daschw commented Nov 2, 2017

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

@mkborregaard
Copy link
Member

mkborregaard commented Nov 2, 2017

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

@mkborregaard
Copy link
Member

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

@mkborregaard
Copy link
Member

mkborregaard commented Nov 2, 2017

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
Copy link
Member

daschw commented Nov 2, 2017

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
Copy link
Member

🙏

@jheinen
Copy link
Member

jheinen commented Nov 3, 2017

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

@ccmejia
Copy link

ccmejia commented May 28, 2021

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
Copy link
Member

@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
Copy link
Contributor

jks-liu commented Dec 14, 2021

Maybe same as #694 and #673

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants