LaTeX y-axis tick labels introduce additional spacing
Autoparallel opened this issue · 1 comments
The Problem
I am working with the following settings for my y-axis:
let y_axis = Axis::new()
.title(Title::new(&y_label).font(Font::new().size(48)))
.show_grid(true)
.grid_color(PRIMITIVE_GREYS[MAIN_COLOR_SLOT])
.zero_line(false)
.show_line(true)
.tick_prefix("$\\LARGE{")
.tick_suffix("}$")
.tick_font(Font::new().size(24))
.auto_margin(false)
.range(axes.bounds.1)
.ticks(plotly::layout::TicksDirection::Outside);
The issue here is that with the chosen .tick_prefix
, the y-axis tick labels (except for the first) have additional spacing that makes the labels collide with the y-axis title. My workaround has been to increase the font size of the y-axis title which does not change the visible font size when you are rendering TeX.
Here is an example output image:
By increasing the size to 55, the collision can be avoided:
The real bug here seems to
be the additional whitespace to the right of the y-axis tick labels:
By removing the tick_prefix
and tick_suffix
and putting:
let y_axis = Axis::new()
.title(Title::new(&y_label).font(Font::new().size(48)))
.show_grid(true)
.grid_color(PRIMITIVE_GREYS[MAIN_COLOR_SLOT])
.zero_line(false)
.show_line(true)
.tick_prefix("")
.tick_suffix("")
.tick_font(Font::new().size(24))
.auto_margin(false)
.range(axes.bounds.1)
.ticks(plotly::layout::TicksDirection::Outside);
To reproduce the problem
Use the y_axis
settings above. Of course, ignore the choice of immaterial settings. E.g., just use:
let y_axis = Axis::new()
.title(Title::new(&y_label).font(Font::new().size(48)))
.show_line(true)
.tick_prefix("$\\LARGE{")
.tick_suffix("}$")
.tick_font(Font::new().size(24))
.auto_margin(false)
.range(vec![0.0,4000.0])
.ticks(plotly::layout::TicksDirection::Outside);
For more precise implementation details, visit the repo where this work is occuring: visualization-rs.
This looks like an issue to be raised with the underlying Plotly.js
library, for which this library is just a thin wrapper, but do correct me and reopen if there is an issue in the rust-specific issue.