Arrows in Polar Matplotlib Plot

Jesse

I am trying to plot the phasors of the voltage across the resistor, capacitor, and inductor in an series R-L-C circuit. I have done all of the calculations and I can get a decent plot with just the normal ax.plot(theta,r,....).

I would like to make the phasor vectors look like arrows. I have been trying to use ax.arrow(0,0,theta,magnitude) but it looks like a line still. The gist to the code that I have written is here : GIST

My image that I create is

I tried to follow the example that I found on this list because it is very similar to what I want to accomplish, it produces the following image:

When I run their code on my computer I get

I am on Xubuntu 14.04 and running matplotlib 1.3.1. I do see that the example I am using was using matplotlib 0.99 in 2009.

Any help would be much appreciated.

Dair

Arrow sizes were too big, this:

import matplotlib
import numpy as np
import matplotlib.pyplot as plt

print "matplotlib.__version__   = ", matplotlib.__version__
print "matplotlib.get_backend() = ", matplotlib.get_backend()


# radar green, solid grid lines
plt.rc('grid', color='#316931', linewidth=1, linestyle='-')
plt.rc('xtick', labelsize=15)
plt.rc('ytick', labelsize=15)

# force square figure and square axes looks better for polar, IMO
width, height = matplotlib.rcParams['figure.figsize']
size = min(width, height)
# make a square figure
fig = plt.figure(figsize=(size, size))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c')

r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
ax.plot(theta, r, color='#ee8d18', lw=3)
ax.set_rmax(2.0)
plt.grid(True)

ax.set_title("And there was much rejoicing!", fontsize=20)
#This is the line I added:
arr1 = plt.arrow(0, 0.5, 0, 1, alpha = 0.5, width = 0.015,
                 edgecolor = 'black', facecolor = 'green', lw = 2, zorder = 5)

# arrow at 45 degree
arr2 = plt.arrow(45/180.*np.pi, 0.5, 0, 1, alpha = 0.5, width = 0.015,
                 edgecolor = 'black', facecolor = 'green', lw = 2, zorder = 5)

plt.show()

Produces:

enter image description here

Better? :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Matplotlib Polar Plot with Lines

From Dev

Rotate theta=0 on matplotlib polar plot

From Dev

How to format a polar contour plot in matplotlib

From Dev

turn off axis border for polar matplotlib plot

From Dev

Move radial tick labels on a polar plot in matplotlib

From Dev

Matplotlib - Drawing a smooth circle in a polar plot

From Dev

Python/Matplotlib Inverse Fill of Polar Plot Polygon

From Dev

Matplotlib polar bar-plot legend

From Dev

Python polar clock-like plot with matplotlib

From Dev

Polar plot gives wrong angles in matplotlib

From Dev

How to rotate theta ticklabels in a matplotlib polar plot?

From Dev

Matplotlib polar plot is not plotting where it should

From Dev

Python/Matplotlib Inverse Fill of Polar Plot Polygon

From Dev

Matplotlib: Polar plot axis tick label location

From Dev

matplotlib polar plot set label position

From Dev

Matplotlib - contour and quiver plot in projected polar coordinates

From Dev

how to set the size of the polar plot in matplotlib?

From Java

plot multiple arrows between scatter points - Matplotlib

From Dev

matplotlib zorder of elements in polar plot superimposed on cartesian plot

From Dev

How to set the axis limit in a matplotlib plt.polar plot

From Dev

How to change the location the 'r' axis for matplotlib polar plot?

From Dev

Plot a (polar) color wheel based on a colormap using Python/Matplotlib

From Dev

Vary length of arrows in Matplotlib Axes3D.quiver plot

From Dev

How to plot a polar plot?

From Dev

Polar contour plot in Maxima

From Dev

Scatter polar plot in matlab

From Dev

Polar plot coordinates are wrong

From Dev

Polar plot thetagrid label

From Dev

Polar plot coordinates are wrong

Related Related

HotTag

Archive