Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

Adjusting coordinate system when using Geom.subplot_grid fails

Open emilbayes opened this issue 8 years ago • 4 comments

I've been looking through previous issues and google, but haven't found a solution to defining a custom plotting range in subplot_grid. I specifically Have discrete integer data from 1900:2015, but Coord.cartesian cannot be applied to a subplot_grid. Is this possible?

emilbayes avatar Oct 20 '15 12:10 emilbayes

Have you tried doing Geom.subplot_grid(Coord.cartesian())?

tlnagy avatar Oct 07 '16 01:10 tlnagy

I just ran into this too and it looks like my proposed solution doesn't work.

using DataFrames, Gadfly
srand(123)
a = DataFrame(:a=>rand(20).*15, :b=>rand(20), :c=>rand(0:1, 20))

plot(a, x=:a, y=:b, xgroup=:c, Geom.subplot_grid(Geom.line))

image

Clipping doesn't work

plot(a, x=:a, y=:b, xgroup=:c, Geom.subplot_grid(Geom.line, Coord.cartesian(xmax=10)))

image

Expansion does?

plot(a, x=:a, y=:b, xgroup=:c, Geom.subplot_grid(Geom.line, Coord.cartesian(xmax=30)))

image

Thoughts @bjarthur and @Mattriks?

tlnagy avatar May 23 '18 01:05 tlnagy

For people coming across this issue, Guide.xticks works for me in a similar case. Even with multiple layers inside Geom.subplot_grid.

rikhuijzer avatar Mar 31 '21 11:03 rikhuijzer

I had the same issue when trying to constrain the y range of the subplots. Interestingly the labels and ticks on the y axis get adapted in all subplots. In subplots where the entire line of plots (i.e. plots sharing the same y scale) has no data outside (ymin, ymax) the plots are correct, however, otherwise the labels and ticks are shown correctly (albeit squeezed together accordingly) while the scale of the actual plot doesn't change and data is still plotted over the entire range (i.e. outside of (ymin, max)).

mhinsch avatar Jul 06 '21 13:07 mhinsch