I want to change the colour scheme of the 3D surface plot in the plotly python. Plotly assigns the colour scheme by default as shown in figure below.
Here is my code
import import plotly.graph_objects as go
import pandas as pd
data = pd.read_csv('\Data.csv')
data.set_index("years", inplace = True)
figure = go.Figure(data=[go.Surface(z=data.values)])
figure.update_layout(
scene = dict(
xaxis = dict(
title = 'Months',
#nticks = 5,
autorange='reversed',
showgrid=True,
gridwidth=1,
gridcolor='Blue',
ticktext = data.columns,
tickvals= list(range(0,data.shape[1]))),
yaxis = dict(
title = 'years',
showgrid=True,
gridwidth=1,
gridcolor='Blue',
ticktext = data.index,
tickvals= list(range(0,data.shape[0]))),
zaxis = dict(
title = 'Discharge (Cumecs)',
#showgrid=True,
gridwidth=1,
gridcolor='Blue')),
tilte = 'Plot 1'
)
You can easily change the colour scheme through colorscale
in
go.Surface(colorscale ='<color>')
Here's an example using colorscale='Blues
:
fig = go.Figure(data=[go.Surface(z=z_data.values, colorscale ='Blues')])
Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Viridis,Cividis.
import plotly.graph_objects as go
import pandas as pd
# Read data from a csv
z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')
fig = go.Figure(data=[go.Surface(z=z_data.values, colorscale ='Blues')])
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
width=500, height=500,
margin=dict(l=65, r=50, b=65, t=90))
f = fig.full_figure_for_development(warn=False)
fig.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.