Coordinates¶
coord_axes_inside¶
- class plotnine_extra.coord_axes_inside(xlim=None, ylim=None, expand=True, xintercept=0.0, yintercept=0.0, labels_inside=False)[source]¶
Bases:
plotnine.coord_cartesianCartesian coordinates with axes drawn inside the panel.
- Parameters:
xlim – Same as
coord_cartesian.ylim – Same as
coord_cartesian.expand (bool) – Same as
coord_cartesian.xintercept (float, default 0) – x-position at which the y axis spine should sit.
yintercept (float, default 0) – y-position at which the x axis spine should sit.
labels_inside (bool, default False) – If
True, tick labels are drawn alongside the relocated spine; otherwise the standard outer labels are kept.
Notes
Plotnine 0.15/0.16 does not expose a post-draw hook on the coord class. This implementation therefore wraps
ggplot.draw()via__radd__so thatapply_axes_inside()is invoked on the resulting matplotlibFigureafter plotnine finishes rendering. The standard axis spines are otherwise left alone bycoord_cartesian.- is_linear = True¶
apply_axes_inside¶
- plotnine_extra.apply_axes_inside(figure, xintercept=0.0, yintercept=0.0, labels_inside=False)[source]¶
Reposition the axis spines of every
Axesinfigureso that they cross at(xintercept, yintercept).This is the manual half of
coord_axes_inside. Call it afterggplot.draw():fig = (p + coord_axes_inside(xintercept=5)).draw(show=False) apply_axes_inside(fig, xintercept=5)