Home > other >  Plotly mapping problem
Plotly mapping problem

Time:09-15

I use the following code to display a scatter diagram and the line chart, but in the end can only display a scatter diagram, want to ask is why?
The from inland_get import inland_peak_get_data # crawler is to write their own code
The from plotly. Graph_objs import Scatter, Layout
The import plotly. Offline as py
The import plotly. Graph_objs as go
Import a datetime
The import numpy as np
The import plotly. Offline as py
The from scipy. Interpolate the import interp1d
Def to_unix_time (dt) :
Epoch=datetime. Datetime. Utcfromtimestamp (0)
Return (dt - epoch). Total_seconds () * 1000

Num=inland_peak_get_data (' nowConfirm ') # data
X_datatime=[]
For people in num: # x date
Riqi=people [1]
Make, ri=map (int, riqi. Split ('. '))
X_datatime. Append (datetime. Datetime (year=2020, the month=make, day=ri))
# start smoothing
X_new1=np. Array ([I for I in range (len (x_datatime)])
Y_new1=np. Array ([country [0] for the country in num])
Xnew=np. Linspace (x_new1 [0], x_new1 [1], num=len (x_datatime) * 2, the endpoint=True)
Func=interp1d (x_new1 y_new1, kind='cubic', bounds_error=False)
Ynew=func (xnew)
# # # # # # #
Trace1=go. Scatter (
X=xnew,
Y=ynew,
Opacity # x=0.9) still expressed with date, y axis with smooth processing

Trace2=go. Scatter (
X=x_datatime,
Y=[country [0] for the country in num],
Mode='markers',
Name='new toll,
Xaxis='x2) # 2 axis

Data111=[trace1 trace2]
Layout=go. Layout (xaxis=dict (
Showticklabels=False, # set whether display coordinate
X_new1 range=[x_new1 [0], [1]]
),
Xaxis2=dict (
Showticklabels=True, # set whether display coordinate
Range=[to_unix_time (datetime. Datetime,1,1 (2020),
To_unix_time (datetime. Datetime,1,31 (2020)]
))
FIG.=go Figure (data=https://bbs.csdn.net/topics/data111, layout=layout)
Py. The plot (FIG)
  • Related