[Matplotlib-users] Plotting dates on the y-axis of a contour map/ hovmoller
pmhobson at gmail.com
Mon Aug 7 11:49:57 EDT 2017
The contour function can be called in many forms.
Without your data, it's hard to see exactly what's going on, but it looks
like you're using the contour(Z, V) form.
I recommend using the contour(X, Y, Z) form. Passing Y as an array of
datetime-like object should "just work".
If it doesn't, boil this example down to something we can copy-paste into a
terminal/notebook and mess around with. A 5 x 5 array for your Z values and
some of the dates in the format you currently have them should suffice.
On Mon, Jul 10, 2017 at 12:26 PM, vaultron94 <sbuechele at albany.edu> wrote:
> Hello all,
> So I ran into a snare when making a Hovmoller for a case study. I have
> everything done and colors picked out. But for the life of me cannot find a
> way to get the Y-axis to plot the dates provided in the data. Here is the
> script I have.
> import numpy as np
> import datetime
> import matplotlib.pyplot as plt
> import os
> import pandas as pd
> def cmap(cmap):
> cmap = plt.cm.get_cmap(cmap)
> data = pd.read_excel('/Users/operator/Documents/Hovmoller_dewpt.xlsx')
> time= (a[:,0])
> lat= (a[:,1])
> lon= (a[:,2])
> BATA= (a[:,3])
> BSPA= (a[:,4])
> BUFF= (a[:,5])
> CLIF= (a[:,6])
> FAYE= (a[:,7])
> HERK= (a[:,8])
> JOHN= (a[:,9])
> JORD= (a[:,10])
> OPPE= (a[:,11])
> WEST= (a[:,12])
> timeZ= (a[:,13])
> plt.contourf(b, np.arange(40,67), cmap=('jet'))
> plt.xlabel('BUFF BATA CLIF JORD FAYE WEST HERK OPPE JOHN BSPA')
> plt.title('Dewpoint Hovmoller for Mesonet Sites')
> #timeZ contains the dates I want, and instead of having the number of rows
> as the y axis I want the dates there instead. Attached is the graphic I get
> as of now. Any thoughts or advice is much appreciated!
> Thank you
> View this message in context: http://matplotlib.1069221.n5.
> Sent from the matplotlib - users mailing list archive at Nabble.com.
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users