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

RFC: Implement line_z and fill_z for GR #1110

Merged
merged 5 commits into from
Sep 27, 2017
Merged

Conversation

daschw
Copy link
Member

@daschw daschw commented Sep 26, 2017

This allows to have lines with colors corresponding to a value, multi-colored lines, "heatmaps" with custom shapes, ... e.g.

using Plots; gr()

σs = 0.5:0.1:2
normal_x = linspace(-5, 5, 100)
normal_y = [exp.(-normal_x.^2 / (2σ^2)) / (2π * σ^2) for σ in σs]

xs, ys = Plots.unzip(Plots.partialcircle(0, 2π, 50, 0.5))
shapes = [Shape(xs + i, ys + j) for i in 1:10, j in 1:10]
zvals = [i * j for i in 1:10, j in 1:10]

y = cumsum(randn(1000))

plot(
    plot(normal_x, normal_y, line_z = σs'),
    plot(shapes, fill_z = zvals),
    plot(y, line_z = y),
    plot(y, fillrange = 0, fill_z = y, fillcolor = :grays),
    label = ""
    )

used to look like this:
gr_line_z_old

Now it produces:
gr_line_z
If this behaviour is desirable implementations for PyPlot and Plotly will follow.

@mkborregaard
Copy link
Member

Sweet! 💯

@mkborregaard
Copy link
Member

mkborregaard commented Sep 26, 2017

I think fill_z is implemented for PyPlot and Plotly, though, but to do something different - to custom color individual facets of surface plots (#641)

@daschw
Copy link
Member Author

daschw commented Sep 26, 2017

I think fill_z is implemented for PyPlot and Plotly, though, but to do something different - to custom color individual facets of surface plots (#641)

OK, thanks for the info! Then I should probably implement this for GR as well. I guess the behaviour of the last subplot is probably not required that often, but I can still implement the fill_z behaviour of the top right subplot.

@mkborregaard
Copy link
Member

Cool. Might it create some confusion that fill_z means two different things then? (not sure)

@daschw
Copy link
Member Author

daschw commented Sep 26, 2017

Does it? I always understood the marker_z, line_z and fill_z attributes as possibilities to provide an additional value which is translated into colors (of a gradient) and can be interpreted via a colorbar. For markers it's marker_z, for lines line_z and for filled areas fill_z. Filled areas can appear in surfaces, shapes and fillranges. <- That's how I would read it ... Not sure if it's too confusing or not consistent enough (shapes also have lines/strokes, markers have lines/strokes and filled areas ...)

@mkborregaard
Copy link
Member

No, I agree. But @tbreloff 's use of the term when used to color the facets in a surfaceplot is not consistent with that logic...

@mkborregaard
Copy link
Member

But maybe it's consistent from the user's perspective, as you point out 👍

@daschw daschw merged commit fba1c66 into JuliaPlots:master Sep 27, 2017
@mkborregaard
Copy link
Member

I really love this enhancement.

@daschw
Copy link
Member Author

daschw commented Sep 28, 2017

Cool, I don't know how to implement Tom's facet color fill_z from PyPlot and Plotly for GR, though. I could not figure out how to color the facets of a surface in GR yet ...

@mkborregaard
Copy link
Member

I guess that's why that is not implemented yet...

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

Successfully merging this pull request may close these issues.

None yet

2 participants