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

Windhistory - draw the wind speed curve with varying color, as a function of the wind direction #3

Open
jmvuilla opened this issue Dec 29, 2016 · 3 comments

Comments

@jmvuilla
Copy link
Owner

The current wind history graph shows the wind speed, with no information related to the wind direction.

Proposal is to combine wind speed & wind direction in a single plot, by using different colors, based on the wind direction.
See http://stackoverflow.com/questions/8945699/gnuplot-linecolor-variable-in-matplotlib/18516488#18516488 for a possible solution.

@jmvuilla
Copy link
Owner Author

jmvuilla commented Jan 8, 2017

First working version, developed in a sandbox (outside GCP).

import matplotlib.pyplot
import matplotlib.collections
import numpy

x = numpy.array(range(20))
y = numpy.array([10,11,12,11,14,10,9,15,17,19,17,15,15,13,10,9,9,13,16,20])
z = numpy.array([0,0,0,340,350,10,45,90,90,90,45,22.5,0,270,292,22.5,45,45,0,0])
points = numpy.array([x,y]).T.reshape(-1,1,2)
segments = numpy.concatenate([points[:-1], points[1:]], axis=1)

matplotlib.pyplot.title("Vitesse du vent a Lery-Poses")
matplotlib.pyplot.xlabel('Temps')
matplotlib.pyplot.ylabel('Vitesse (km/h)')
matplotlib.pyplot.grid(True)

lc = matplotlib.collections.LineCollection(segments, cmap=matplotlib.pyplot.get_cmap('Spectral'),norm=matplotlib.pyplot.Normalize(0,360))
lc.set_array(z)
lc.set_linewidth(2)
matplotlib.pyplot.gca().add_collection(lc)
matplotlib.pyplot.xlim(0,20)
matplotlib.pyplot.ylim(0,25)
cbar = matplotlib.pyplot.gcf().colorbar(lc,ticks=[0,45,90,135,180,225,270,315,360])
cbar.ax.set_yticklabels(['N','NE','E','SE','S','SO','O','NO','N'])
cbar.set_label('Direction du vent (en degres)')

matplotlib.pyplot.show()

@jmvuilla
Copy link
Owner Author

jmvuilla commented Jan 8, 2017

screenshotproto

@jmvuilla
Copy link
Owner Author

jmvuilla commented Jan 8, 2017

Might want to show the colorbar as a circle iso a simple bar.

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

No branches or pull requests

1 participant