(See Screenshot) OHLC plots, what looks like, two separate graphs side by side, one red and one black, with xaxis time sequence out of order; instead of one graph with the time sequence in correct order with red and black mixed together. Why?

Here’s my javascript and then a screenshot of my graph with another screenshot of a correct graph from plotly website. Why is this happening?

var trace1 = {
  type: 'ohlc',
  x: timearr, 
  open: openarr,  
  high: higharr,  
  low: lowarr,
  close: closearr,
  increasing: {line: {color: 'black'}}, 
  decreasing: {line: {color: 'red'}},
  xaxis: 'x', 
  yaxis: 'y'

var data = [trace1];

var layout = {
  dragmode: 'pan',
  showlegend: true,
  xaxis: {
    rangeslider: {
		 visible: true
  yaxis: {exponentformat: "none"}

Plotly.newPlot('popup', data, layout);

My Graph

A Correct Looking Graph

You must not be inputting correctly formatted date strings and plotly.js think you’re plotting categorical data.

See https://help.plot.ly/date-format-and-time-series/#step-2-entering-dates-and-times-in-plotly-s-grid for more info

1 Like

Thanks for your reply. If there is something wrong with the dates I can’t figure out what. With every graph type I’ve tried, except OHLC and Candlestick,the dates plot correctly. The dates are in order. Plotly takes them out of order and makes two orders: one string of dates (in sequential order) for the down days, and one string of dates (in sequential order) for the up days.

You were right about the date formatting. That was the problem. Thanks very much.

1 Like