[Chart] Grid + Legend problems
Tim Docker
tim at dockerz.net
Tue Jan 28 20:14:47 GMT 2014
Thanks. The pictures explain what is going on - the behaviour is expected.
A renderable has a size, which corresponds to the smallest dimensions at
which it can be drawn.
The grid was designed for layout of the internal plot element, and has
the following behaviour:
a) When laying out a row, the initial height of a row is equal to the
maximum height of all the renderables in that row.
b) When laying out a column, the initial width of a column is equal to
the maximum width of all the renderable in that row.
c) If a grid is given more space that required to layout the renderables
at minimum size, then the weights are used to determine how the extra
space is allocated to the rows/columns
The charts you show have different minimum sizes due to the different
legends (on these charts the legend is the widest element, so ends up
controlling the size). Even weights just means that that the amount of
extra space allocated to each is the same.
Note there is nothing specific to legends here - the legend just happens
to be the widest element of your charts. You could see the same problem
if you had long titles of inconsistent size.
To do what you need, I think an extra grid function may be required:
evenSizing :: Grid (Renderable a) -> Grid (Renderable a)
This would replace each renderable in the grid with another which
renders the same, but returns a width consistent with all the other
renderables in the same column, and a height consistent with all the
other renderables in the same row.
Tim
On 29/01/14 05:22, Sacha Sokoloski wrote:
> Here's a couple images which I hope convey what I mean.
>
> They were both generated with the command:
>
> P.gridToRenderable . P.weights (1,1) $ P.tallBeside hstlyt (P.tval errlyt)
>
> where hstlyt and errlyt are the to layouts, which have already been
> converted to renderables. The only difference otherwise is in having
> set layout_legend to Nothing.
>
> Thanks,
>
> - Sacha
>
> On 22/01/14 09:59 AM, Tim Docker wrote:
>>
>> Hi.
>>
>> Sorry for the slow response.
>>
>> Its hard to understand your exact problem without either some sample
>> code or at least an image. Can you provide this?
>>
>> Tim
>>
>> On 7 Jan 2014 03:18, "Sacha Sokoloski" <sokolo at mis.mpg.de
>> <mailto:sokolo at mis.mpg.de>> wrote:
>>
>> So I've finally, at least partially, isolated an issue with Chart
>> that has bothered me forever.
>>
>> When using Grids, I've always noticed that even when the space
>> weights are the same (i.e. (1,1)), the various sub-renderables
>> would come out to be different sizes, proportionally. That is,
>> one plot might take up 2/3 of the screen, and the other 1/3.
>>
>> I noticed that if I set the space weight to 0 for a pair of grids
>> beside each other, then the grid with the longer legend (i.e. the
>> one with more elements in the legend) would still be drawn
>> larger, even though they should both only take one cell. This
>> gets magnified when given full space weighting, so that plots
>> with larger legends will take up more space. If I set legends to
>> be Nothing in all the relevant layouts, then the grids end up
>> equal in size.
>>
>> So that's great! I still wouldn't have much idea as to how to fix
>> this though. Is there anyway this could be moved along?
>>
>> I also still have an implementation of contour plots kicking
>> around which one day I should try to integrate into Chart properly...
>>
>> Cheers,
>>
>> - Sacha
>>
>> _______________________________________________
>> Chart mailing list
>> Chart at projects.haskell.org <mailto:Chart at projects.haskell.org>
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/chart
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/chart/attachments/20140129/6893bb2b/attachment.htm>
More information about the Chart
mailing list