I'm trying to make my plots look like this:
That is:
- Solid lines at the left/bottom edge for the plot axes, but not a closed box
- Ticks only on the axes, not on the opposite edge.
This question and solution provide two pieces of information:
- Those lines are called "spines"
- They can be deactiveted separately via
axes.spines.<xxx>
However, that does not seem to work on my end:
>>> plt.matplotlib.__version__
'1.3.1'
>>> plt.rcParams['axes.spines.top'] = False
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\<username>\Software\WinPython-64bit-2.7.6.4\python-2.7.6.amd64\lib\site-packages\matplotlib\__init__.py", line 811, in __setitem__
See rcParams.keys() for a list of valid parameters.' % (key,))
KeyError: 'axes.spines.top is not a valid rc parameter.See rcParams.keys() for a list of valid parameters.'
Removing the spines after the fact seems to work though:
>>> ax.spines["top"].set_visible(False)
>>> ax.spines["right"].set_visible(False)
So the best I've achieved so far is this:
This still has all the tick marks and is missing a grid line at the right edge (but interestingly enough not at the top)
How can I have the ticks just one one side, too?
I've seen pyplot plots with ticks on one side (example, from here) but have not been able to figure out how to do this. All the tick settings I've found so far only specify width, length, position (along the axis, in/out), or turn them all on/off.
Ideally, I'd like to achieve this by creating a modified matplotlibrc
, so I can just load that and have everything use the same style.
I'm still on matplotlib 1.3.1 (not my choice but hard to change now). If I had to, I could save the data and process it in an up-to-date version, though I'd prefer to avoid that.