3

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

asked May 17, 2017 at 5:09
3
  • What have you tried so far? Mock up some data, give it your best try, and then post that. Commented 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. Commented 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. Commented May 18, 2017 at 4:09

1 Answer 1

3

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.

answered May 18, 2017 at 4:02

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.