python


Subplot of Windrose in matplotlib


I am trying to make a figure with 4 subplots of windrose, But I realised that the windrose only have axis like this:ax = WindroseAxes.from_ax() So, how can I draw a subplots with windrose?
There are two solutions:
(a) creating axes from rectangles
First of all there is a similar question already here: How to add specific axes to matplotlib subplot?
There, the solution is to create a rectangle rect with coordinates of the new subplot axes within the figure and then call ax = WindroseAxes(fig, rect)
An easier to understand example would be
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import numpy as np
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
fig=plt.figure()
rect=[0.5,0.5,0.4,0.4]
wa=WindroseAxes(fig, rect)
fig.add_axes(wa)
wa.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
plt.show()
(b) adding a projection
Now it may be rather annoying to create this rectangle and it would be much better to be able to use the matplotlib subplot functionality.
One suggestion that has been made here is to register the WindroseAxes as a projection into matplotlib. To this end, you need to edit the file windrose.py in the site-packages/windrose as follows:
Include an import from matplotlib.projections import register_projection at the beginning of the file.
Then add a name variable :
class WindroseAxes(PolarAxes):
name = 'windrose'
...
Finally, at the end of windrose.py, you add:
register_projection(WindroseAxes)
Once that is done, you can easily create your windrose axes using the projection argument to the matplotlib axes:
from matplotlib import pyplot as plt
import windrose
import matplotlib.cm as cm
import numpy as np
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
fig = plt.figure()
ax = fig.add_subplot(221, projection="windrose")
ax.contourf(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot)
ax.legend(bbox_to_anchor=(1.02, 0))
plt.show()

Related Links

using python to verify that a shapefile is a shapefile (fiona, ogr)
Identifying largest connected component in a matrix
VBA shell script set environment variable before execution
Embed matplotlib in PyQt
Odoo - overriding old api method with new api?
Pylint warning - W5304(Missing-Test-Class)
In terms of efficiency/quickly rejecting things, does it matter if your if statements are on the same line?
QComboBox drop-down list adding unnecessary scroll bar
Specify color type for bar graph pylab
prettifying a part of the html doc using beautifulsoup
Django concatenate two querysets for same model
How can I validate input to accept only binary numbers?
Custom route predicates in Pyramid
Why is my query for a structured property failing with BadFilterError?
Simple Audio Units Host to drive an Audio Units Instrument
kivy language cumbersomeness and rationale behind it

Categories

HOME
app-inventor
answer-set-programming
elixir
reverse-engineering
visual-studio-2013
google-tag-manager
cpu-architecture
csvhelper
rocketmq
console
pygame
dryioc
squarespace
cratedb
scala-native
uisplitviewcontroller
netezza
ssms-2016
yeoman-generator
quartus
chocolatey
jive
ng2-dragula
k2
piwik
rworldmap
restfb
nmf
philips-hue
badge
guile
ui5
image-quality
cgal
mayavi
invoke-command
vegan
xor
rowcount
viewstate
nunit-3.0
forecasting
readfile
discord.net
android-download-manager
silverlight-3.0
fltk
cross-entropy
lexical-analysis
nsexception
context-free-language
startapp
email-parsing
dimple.js
broadcast
livescribe
goquery
rollback
ticker
ruby-on-rails-2
addin-express
lotus
createobject
alter
packagemaker
c#-interactive
wcf-ria-services
tomcat5
radians
inotifypropertychanged
mongo-c-driver
remoteapp
logcat
xmp
except
eyeql
fabric-twitter
mogrify
on-duplicate-key
digits
guzzle6
jcr-sql2
sysctl
grunt-contrib-concat
collabnet
funq
funkload
sgml
help-viewer
xenocode
ng-hide
sttwitter
visual-studio-2003
ng-pattern
device-emulation
osi
qsqltablemodel
radchart
text-size
scraperwiki
pantheios
communicationexception
openvg
web-statistics
evb
handheld
database-diagramming
visual-studio-dbpro

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App