Two y-axis in a Gizmos TimeSeries object

9 views
Skip to first unread message

Gonzalo Espinoza Davalos

unread,
Jan 12, 2016, 2:59:52 PM1/12/16
to Tethys Platform
Is there a way too plot two variables with two axis using the Gizmos TimeSeries object?

I have two variables A and B (see attached) and I can only plot both variables using the same axis (top figure) and I'd like to plot both variables with two y-axis (bottom figure).

It will be neat to have this functionality.
Secondary_axis.png

swainn

unread,
Jan 12, 2016, 3:48:29 PM1/12/16
to Tethys Platform
I've not tried it before in Tethys, but Highcharts can do it (look at the definition for the yAxis): 


We tried to make the plot views so that you could override anything and use the raw highcharts API. To do this, just pass the yAxis parameter as an argument to the plot, using the Python equivalent of the highcharts API. For example:

line_plot_view = LinePlot(
  height='500px', 
  width='500px', 
  engine='highcharts', 
  title='Plot Title', 
  subtitle='Plot Subtitle', 
  spline=True, 
  x_axis_title='Altitude', 
  x_axis_units='km', 
  y_axis_title='', 
  y_axis_units='',
  yAxis=[{
      'labels':  { 'format': '{value}*C', }, 
      'title': { 'text': 'Air Temperature', },
      'opposite': true 
     }, {
      'gridLineWidth': 0, 
      'title': { 'text': 'Water Temperature', }, 
      'labels': { 'format': '{value}*C', } 
    }],
  series=[ {
      'name': 'Air Temp', 
      'color': '#0066ff',
      'marker': {'enabled': False},
      'yAxis': 0, 
      'data': [ [0, 5], [10, -70], [20, -86.5], [30, -66.5], [40, -32.1], [50, -12.5], [60, -47.7], [70, -85.7], [80, -106.5] ] 
     }, {
      'name': 'Water Temp', 
      'color': '#ff6600',
      'yAxis': 1,
      'data': [ [0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1], [50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5] ] 
    } ] 
)

Disclaimers: There were some issues with version 1.2.0 being able to override the axis, but they have been addressed for version 1.3.0 which is forth coming. 
Reply all
Reply to author
Forward
0 new messages