I have been trying to create a contour plot using plot.ly in Python (Jupyter Notebook). The data set comprises of 366 units in the X-axis and 216 units in the Y-axis. Hence the axes display values from 0 to 365 and 0 to 215 in the X and Y axes respectively.
- I want to label the X-axis to display equally spaced names of 12 months. ie., Jan, Feb, .., Dec, and Y-axis to show only 3 points labelled -30, 0, and 30.
- I want to create a line through the points of maxima.
How can I do these?
What I've done so far is:
fig = [
go.Contour(
z=data_set,
colorscale=[[0, 'rgb(204,229,255)'], [0.15, 'rgb(153,204,255)'],
[0.3, 'rgb(102,178,255)'], [1, 'rgb(0,51,102)']]
)]
py.iplot(fig)
where z is a list of lists of 366x216 data points (ie., 366 lists inside z each of which contains 216 values). I'm getting a plot as follows: plot
-
What have you tried so far? Mock up some data, give it your best try, and then post that.Mike Wise– Mike Wise2017年05月17日 07:33:03 +00:00Commented May 17, 2017 at 7:33
-
I've added the code and the plot I've been able to produce so far. Hope it helps.navajyothmp– navajyothmp2017年05月17日 13:14:27 +00:00Commented May 17, 2017 at 13:14
-
At last, I could sort out the first problem of custom labeling the plot. But, I still have no idea how to take on the second issue of creating a line connecting the points of maxima in the same contour plot.navajyothmp– navajyothmp2017年05月18日 04:09:28 +00:00Commented May 18, 2017 at 4:09
1 Answer 1
I've found out that the first problem of custom labeling can be done as follows:
hy = 216/2.0
hx = 366/12.0
layout=dict(
xaxis=dict(
tickvals=[(2*k-1)*hx/2 for k in range(1,13)],
ticktext=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',]
),
yaxis=dict(
tickvals=[k*hy for k in range(3)],
ticktext=[-30, 0, 30]
)
)
But, I still have no idea how to proceed with the second one.