Open alecello opened 4 years ago
DPI is necessary even though we only save the graph since matplotlib
dimensions only work, as far as I know, in inches, meaning we still need a DPI. This has an advantage: we can make real-world measurements on drawings and apply them as sensible defaults.
Right now graph dimensions are determined with a constant value for pie charts and a value proportional to the number of bars for bar charts, with a completely arbitrary value added to them in order to account for graph title and axis name.
While this is good enough, it generates graphs for which the single column width is not of a fixed size, graphs in which the title space is tight or too large, and appearance variations which are undesirable. In some edge cases, it might even create an overlapped mess of colors and text.
Ideally, dimensions should be determined as follows:
Then use all the previous values to compute exact dimensions for:
The figure size should be the least value that can contain all its children.
The plot area (graph + title + legend + axis) should be the least value that can contain all its children, plus some whitespace on either side to have the aspect ratio match (unless the ratio is zero, in which case this last step is skipped).
The graph area should be calculated by using class and spacing values. For pie charts, the class is just one, for bar charts it's the number of bars. Spacing is in between classes (if there are many) and above the first class and below the last class.
This way the graph should be completely deterministic in aspect no matter the datasize or graph type.