echarts4r comes with a highly customisable grid and axis, but admittedly they take some getting used to.
You can customise the axis with
e_y_axis, you can see the official documentation for more details. There is also a helper function,
e_format_axis and its sisters
e_format_y_axis. The latter lets you easily add suffix or prefix to your axis labels.
Say you want to plot percentages against ceslius.
You can also customise the grid to have, for instance, multiple plots on one canvas.
Let’s initialise a basic plot.
Now say we don’t want
z on the same plot. We could of course make two entirely different plots (2 plots initialised with
e_charts()), but it would be cleaner to have them on the same canvas, a bit like ggplot2 facets.
First two plots on the same canvas means multiple axis, so we’ll plot each serie on its own axis.
y indices default to 0 so we only need to change one of the series’ indices to 1. Therefore one serie is plotted on index 0 and the other on index 1 for two
echarts4r puts the additional axis on the top and right of the plot. This is a useful feature but not what we want; we’re missing a split grid.
e_grid twice for two grids, we define the height of each;
35% is ideal for stacked grids, you need some margin for the legend, the axis, etc. hence not using
However, we still have both line plots on the same grid. Here is how to think about grids and axis in
e_line) are plotted against axis (
So we have two grids and two axis but the axis are both plotted on the same grid(point #2 above). So we need to move our two additional axis to another grid. Note that grid indices also start at 0 here.
There you go!
You can also have a different grid to put the plots side by side.
Well now those charts can share interactions.
You can also mess with the axis to completely change your chart. For instance, from a regular bar chart:
to a polar chart.
or a radial chart one.
This will also work with other chart types.