Are dotted/dashed colored vectors possible in matplotlib quiver? - matplotlib

I am working on a project and we decided to use matplotlib.
For a polar chart we have a bunch of colored vectors which need to be recognizable from each other.
Now I have been able to get this:
Quiver add is simply:
Q.append(sub.quiver(0,y_min_max[0], real_coords[i], imag_coords[i], color=color, scale=y_min_max[1]*2, zorder=5)
But is it possible to have dashed colored vectors?
The closest answer I found is this one Plotting dashed 2D vectors with matplotlib?
Which is close but I've only managed to get colored vectors surrounded with dashed lines instead of dashed vectors
Q.append(sub.quiver(0,y_min_max[0], real_coords[i], imag_coords[i], color=color, scale=y_min_max[1]*2, zorder=5, linewidth=0.5, linestyle = '--'))
I've been experimenting with various combinations but no luck for now, any ideas?
Thanks in advance

Related

Turn off x-axis marginal distribution axes on jointplot using seaborn package

There is a similar question here, however I fail to adapt the provided solutions to my case.
I want to have a jointplot with kind=hex while removing the marginal plot of the x-axis as it contains no information. In the linked question the suggestion is to use JointGrid directly, however Seaborn then seems to to be unable to draw the hexbin plot.
joint_kws = dict(gridsize=70)
g = sns.jointplot(data=all_data, x="Minute of Hour", y="Frequency", kind="hex", joint_kws=joint_kws)
plt.ylim([49.9, 50.1])
plt.xlim([0, 60])
g.ax_joint.axvline(x=30,ymin=49, ymax=51)
plt.show()
plt.close()
How to remove the margin plot over the x-axis?
Why is the vertical line not drawn?
Also is there a way to exchange the right margin to a plot which more clearly resembles the density?
edit: Here is a sample of the dataset (33kB). Read it with pd.read_pickle("./data.pickle")
I've been fiddling with an analog problem (using a scatterplot instead of the hexbin). In the end, the solution to your first point is awkwardly simple. Just add this line :
g.ax_marg_x.remove()
Regarding your second point, I've no clue as to why no line is plotted. But a workaround seems to be to use vlines instead :
g.ax_joint.vlines(x=30, ymin=49, ymax=51)
Concerning your last point, I'm afraid I haven't understood it. If you mean increasing/reducing the margin between the subplots, you can use the space argument stated in the doc.

Hide part of an axis in a matplolib figure

How can I modulate the length of the yaxis of a matplotlib plot, as in the following figure:
In addition, how can I modulate the thickness of the yaxis?
I just found the answer. One need to use ax.spines['left'].set_bounds(4, -4).

Using more than two "y" axes with pylab.twinx()

I am plotting three different lines in the same figure using matplotlib in pylab. I want to plot a "y" axis on the right, and two on the left. Now I can plot one on the right and one on the left:
pylab.subplot(311)
pylab.annotate('(a)', xy=(0.03, 1e17), xycoords='data', color='k')
pylab.grid(True)
noxticks()
pylab.semilogy(t[:], pht[:])
pylab.ylabel('Total photons')
pylab.twinx()
pylab.semilogy(t[:], pht2[:])
pylab.ylabel('Received photons 1')
I want to add another y axis on the left to plot also pht3, but I cannot. How could I do that?
Thank you!

matplotlib draw ellipse contour

I am trying to draw something similar:
The main idea is to draw ellipses with different color in some specific range, for example from [-6, 6].
I have understood that plt.contour function can be used. But I do not understand how to generate lines.
I personally wouldn't do this with contour as you then need to add information about the elevation which I don't think you want?
matplotlib has Ellipse which is a subclass of Artist. The following example adds a single ellipse to a plot.
import matplotlib as mpl
ellipse = mpl.patches.Ellipse(xy=(0, 0), width=2.0, height=1.0)
fig, ax = plt.subplots()
fig.gca().add_artist(ellipse)
ax.set_aspect('equal')
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
You then need to research how to get the effect you are looking for, I would have a read of the docs in general making things transparent is done through alpha.

How to create a scatter plot legend with only one symbol for each label?

How can I create a scatter plot legend without two symbols showing up each time? I can understand why you'd want this when you're joining symbols by lines, but for a pure scatter plot, all I want in the legend is one example of the symbol. This plot from a previous stackoverflow post shows the kind of thing I mean:
In the legend command you can use the scatterpoints option:
ax.legend(loc=0, scatterpoints = 1)
For a normal plot, it is the option numpoints.
Here you can find more information about the keyword arguments for the legend: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend