Skip to content

Instantly share code, notes, and snippets.

@thmosqueiro
Last active March 27, 2017 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmosqueiro/1c8167d6eb308a51a2627392a038621f to your computer and use it in GitHub Desktop.
Save thmosqueiro/1c8167d6eb308a51a2627392a038621f to your computer and use it in GitHub Desktop.
import numpy as np
import pylab as pl
from polarError import polarError
f, ax = pl.subplots(1, 1, figsize=(4,1.8) )
bsize = 0.5
theta = np.array( [np.pi*5./4. - bsize, np.pi/2. - bsize, np.pi*7.5/4. - bsize, 0] )
data = np.array( [0.7, 0.3, 0.52, 0.8] )
edata = np.array( [0.2, 0.1, 0.5, 0.2] )
ax = pl.subplot(111, projection='polar' )
ax.set_aspect(0.5)
color = (0.1,0.4,1.0)
ax.bar( theta, data, width=bsize, color=color, edgecolor='none',
ecolor=color, error_kw={"lw" : 0.7})
polarError(ax, data, edata, theta + bsize/2,
color=color, dtheta=0.05)
ax.set_yticks( [0.5, 0.8] )
ax.set_rlabel_position(45+90)
ax.set_ylim(0, 1.1)
ax.set_xticks([])
pl.tight_layout()
pl.savefig('RosePlot_example_fixed.png', dpi=800)
def polarError(ax, r, dr, theta, numpoints = 15, color = (0,0,0),
dtheta = 0.1, lw=0.7):
for j in range( theta.shape[0] ):
for p in [-1, +1]:
local_theta = np.linspace(-dtheta, dtheta, 15) + theta[j]
local_r = np.ones(15) * ( r[j] + p*dr[j] )
ax.plot(local_theta, local_r, color=color, lw=lw, marker='', zorder=-1)
local_theta = [theta[j]]*2
local_r = [ r[j], (r[j] + p*dr[j])*0.999 ]
ax.plot(local_theta, local_r, color=color, lw=lw, marker='', zorder=-1)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment