Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seamless Subplotting #20

Closed
adityasinghwa opened this issue Jan 25, 2016 · 11 comments
Closed

Seamless Subplotting #20

adityasinghwa opened this issue Jan 25, 2016 · 11 comments

Comments

@adityasinghwa
Copy link

Hi! I was trying to use the module to plot a bunch of other weather parameters. The module can only be used for standalone plots. I cannot subplot it within my existing plot setup. I have tried some of the work arounds given but was not successful.

@scls19fr
Copy link
Member

Did you try passing ax parameter ?

@adityasinghwa
Copy link
Author

I did try it. Can you possibly give a sample syntax. My other subplots go something like this:

ax = plt.subplot(514)    
ax.set_ylabel('Cloud Cover (fraction)')
ax.spines["top"].set_visible(False)  
ax.spines["bottom"].set_visible(True)  
ax.spines["right"].set_visible(False)  
ax.spines["left"].set_visible(True) 
ax.get_xaxis().tick_bottom()  
ax.get_yaxis().tick_left()
ax.xaxis.set_major_locator(matplotlib.dates.MonthLocator(bymonth=None, bymonthday=01, interval=4, tz=None))
ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%b %Y'))
line = plt.plot(Date, df.CC, lw=1.5, color='black')
line = plt.plot(Date, movingaverage(df.CC,24), lw=1.0, color='red')

So I need a setup to plot it in position 515.

@scls19fr
Copy link
Member

I faced a similar issue
see https://github.com/scls19fr/windrose/issues/10
but I never had time to fix it.
Feel free to help by submitting a PR

Pinging original author @lionelr

@scls19fr
Copy link
Member

scls19fr commented Feb 4, 2016

It will be great if some Matplotlib experts such as @tacaswell @JanSchulz or @mdboom (or some others) could help on this.

@jankatins
Copy link

@adityasinghwa can you post a minimal example which goes wrong?

@lnlrbr
Copy link

lnlrbr commented Feb 4, 2016

You have to manually set your WindRoseAxes position on the figure, like you have to do with Axes and PolarAxes, because plt.subplot is just a helper function for that. You can achieve that like this

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
ax=plt.subplot(221) # and set whatever you want in this axes
fig=gcf()
rect=[0.6,0.6,0.3,0.3] # have to be calculated with the others axes
wa=WindroseAxes(fig, rect)
fig.add_axes(wa)
wa.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')

figure_1

@scls19fr
Copy link
Member

scls19fr commented Feb 4, 2016

Hi folks,

A subplots example is available at https://github.com/scls19fr/windrose/blob/master/samples/example_subplots.py

See screenshot

capture d ecran 2016-02-04 a 14 20 53

This figure is composed of 12 windrose plots from Poitiers (year 2014, monthly)

It can probably be improved to display month (name or number) as subplots title
Adding margin, spacing might also be considered.

We should also provide a better API to make automatically this kind of plot.
https://github.com/scls19fr/windrose/issues/26

Kind regards

@adityasinghwa
Copy link
Author

adityasinghwa commented Feb 5, 2016

image

Made this one with matlab where plot_windrose.m integrates seamlessly with normal plotting functions inside matlab. It has a analogue to matplotlib's axes_grid functionality which has been used for this plot.

Will give manually trying to fit the axes a go. The problem is then they have to be manually setup for all the plots.

@Data-drone
Copy link

@adityasinghwa can you share a snippet of your code I am trying to do subplots with other charts like you too but I can't work it out

@scls19fr
Copy link
Member

Maybe this https://github.com/scls19fr/windrose/issues/38 could help to have easier subplotting.

@scls19fr
Copy link
Member

WindroseAxes is now a registered projection (as windrose)

we can do

ax1 = fig.add_subplot(131, projection='polar')
ax2 = fig.add_subplot(132, projection='rectilinear')
ax3 = fig.add_subplot(133, projection='windrose')
ax3.bar(dir, vals)

an other example can be found

https://github.com/scls19fr/windrose/blob/master/samples/example_subplots.py#L62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants