Plotly Y勾选标签

时间:2017-11-10 15:20:20

标签: python python-3.x plotly

我试图在y轴上设置自定义标签。

这就是我的布局:

layout = dict(title = 'Tracer',
              dragmode = 'zoom',
               showlegend = True,             
              yaxis = dict(
                            tickvals = yTickValues,
                            ticktext = yTickNames, 
                            showticklabels = True,
                          ),
             )

标签['RwHandlerI2c','OrganizedTxSsp0','PIN_INT5_IRQn']的格式错误。

实验我发现“RwHandlerI2c”标签中的问题在数字“2”中,正确显示名为“RwHandlerIc”的标签。我在格式化中丢失了什么吗?以及如何为标签创建单独的列,因此它们不会与图形重叠。

Example plot

import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import datetime

yTickValues = list(range(8)) 
yTickNames = ['StartSendingSsp0', 'OrganizedTxSsp0', 'I2cRwHandler', 'GpsParser', 'SSP1_IRQn', 'USART0_IRQn', 'RTC_IRQn', 'I2C_IRQn']

xaxis = [datetime.datetime(2000, 1, 1, 0, 0, 0, 686002), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686008), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686045), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686176), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686192), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686523), 
     datetime.datetime(2000, 1, 1, 0, 0, 0, 686530)]

yaxis = list(range(8))

# Create a trace
trace = go.Scatter(
x = xaxis,
y = yaxis,
mode = 'markers'
)

layout = dict(title = 'Tracer',
            yaxis = dict(
                        tickvals = yTickValues,
                        ticktext = yTickNames, 
                        showticklabels = True,
                        )
    )

data = [trace]

fig = dict(data=data, layout=layout)

plot(fig, filename='example')

0 个答案:

没有答案