|
From: Andrew D. <da...@at...> - 2013-01-23 10:19:04
|
Hi all,
[TL;DR: is it possible to control the length of the dashes in dashed
contours, if so how?]
I'd like to be able to control the length of dashes for dashed contours. My
motivation is that I'm making a contour plot that uses dashes for the
negative contours, and the plot needs to be a specific (small) size for the
particular journal, so the small size of the plot makes the dashes look
rather long and is a problem for some tight contours.
I have tried using some a dashes-style argument for the linestyles keyword
of contour but I can't get it to work (although I appreciate it is not
documented as something one can do). For example I tried:
import matplotlib.pyplot as plt
import numpy as np
x = y = np.linspace(-np.pi, np.pi, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(Y)
plt.contour(x, y, Z, linestyles=[(3, 3)])
plt.show()
This fails at the point where I show (or save, doesn't matter which
backend) the plot with a PyCXX error:
TypeError: PyCXX: Error creating object of type
N2Py7SeqBaseINS_6ObjectEEE from 3
I've fiddled with several other styles of argument and all fail in a
similar way.
What I'd like to know is: is it possible to control the dash length of
dashed contours at all? It seems like it should be as one can do this with
lines easy enough. I looked through the code, and a dashes-style argument
seems to get passed through the stack correctly, but fails when the
Collection is drawn. It would be a really nice feature if this could be
implemented in matplotlib.
Thanks,
Andrew
|