python - Python为x和y轴破折号应用程序添加标题
问题描述
我正在尝试创建一个破折号应用程序来创建一些数据的散点图。有人能给我一个提示,让我在绘图的 x 和 y 轴上显示标题吗?似乎我在网上找到的大多数文档似乎都适用于 IPython。布局以这种格式定义:
layout = dict(
title= 'Rank',
ticklen= 5,
gridwidth= 2,
)
但我的 dash 应用程序看起来更像这种格式:编辑以包含下面的所有代码
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
import numpy as np
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('boilerData.csv', index_col='Date', parse_dates=True)
df = df.fillna(method = 'ffill').fillna(method = 'bfill')
app.layout = html.Div([
html.H1('Heating System Temperature Data Visulation'),
html.Center('The purpose of the scatter plot below is to prove if a temperature reset strategy is implemented on the hydronic heating system. At various outside air temperature conditions, the hot water temperature should fluctuate to save energy.'),
dcc.Graph(
id='hwst-vs-oat',
figure={
'data': [
go.Scatter(
x = df.OAT,
y = df.HWST,
mode = 'markers',
marker = dict(
color = '#FFBAD2',
line = dict(width = 1)
)
)
],
'layout':{
'title':'Scatter Plot of OAT versus HWST',
'xaxis':{
'title':'whatever you want x to be'
},
'yaxis':{
'title':'whatever you want y to be'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
任何提示都有帮助,谢谢。
解决方案
应该能够做这样的事情
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
import plotly.graph_objs as go
import numpy as np
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_csv('boilerData.csv', index_col='Date', parse_dates=True)
df = df.fillna(method = 'ffill').fillna(method = 'bfill')
app.layout = html.Div([
html.H1('Heating System Temperature Data Visulation'),
html.Center('The purpose of the scatter plot below is to prove if a temperature reset strategy is implemented on the hydronic heating system. At various outside air temperature conditions, the hot water temperature should fluctuate to save energy.'),
dcc.Graph(
id='hwst-vs-oat',
figure={
'data': [
go.Scatter(
x = df.OAT,
y = df.HWST,
mode = 'markers',
marker = dict(
color = '#FFBAD2',
line = dict(width = 1)
)
)
],
'layout':{
'title':'Scatter Plot of OAT versus HWST',
'xaxis':{
'title':'whatever you want x to be'
},
'yaxis':{
'title':'whatever you want y to be'
}
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
推荐阅读
- codeigniter - Codeigniter,从控制器到视图的多个查询
- javascript - How to bind multiple arrays in one over an loop
- spring-boot - 使用 ZUUL 作为代理通过 URL 访问 Angular 6 组件
- c# - C# if 语句在控制台游戏中不起作用(我是初学者,所以可能完全错误)
- html - 基于设备高度的假响应背景的宽度?
- javascript - 使用 Javascript 在 iPhone 中自动播放视频
- unit-testing - serde 实现中的模拟实例
- assembly - 如何在 64 位 FreeBSD 的汇编程序中调用 Int 80h(系统调用)?
- android - 片段内的listview的adapter.notifyDataSetChanged()崩溃
- android - android - 协调启动其他应用程序的意图