You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This does draw a grid, but it draws it for both axes (ie. the axis keyword is completely ignored). It also draws the grid above the chart (ie. ignoring set_axisbelow(True))
The text was updated successfully, but these errors were encountered:
Drawing grid lines for one axes is impossible with axisartist.
I can think of a few workarounds, but none of them seems to be easy and straight forward. Below is one example.
frompylabimport*importmpl_toolkits.axisartistasAA#from mpl_toolkits.axes_grid1 import host_subplotfig=figure(1)
# Use SubplotHostax=fig.add_subplot(AA.SubplotHost(fig, 111))
ax.bar(range(3), [10, 20, 30])
ax.set_xticks(range(3))
# create a twinx axes, which will be used to draw gridlines.ax2=ax.twinx()
ax.axis["right"].toggle(ticks=True)
ax.axis["right"].line.set_visible(True)
ax2.axis["right"].toggle(all=False)
ax2.axis["right"].line.set_visible(False)
ax2.set_yticks([]) # this removes x-grid lines.ax2.grid()
ax2.gridlines.set_zorder(0.5) # this puts gridlines below other artists.show()
Consider the following code:
With a non-axisartist Subplot object, this will draw horizontal grid lines underneath the bars. However, this code will not draw a grid at all.
After a bit of reading, I discovered the
ax.grid
method, so decided to change the code to read:This does draw a grid, but it draws it for both axes (ie. the
axis
keyword is completely ignored). It also draws the grid above the chart (ie. ignoringset_axisbelow(True)
)The text was updated successfully, but these errors were encountered: