在曲线图中以条形图设置x和y范围

时间:2023-02-09 10:49:54

How to set x and y range in a bar plot. My plot currently likes the following (in python):

如何在条形图中设置x和y范围。我的情节目前喜欢以下(在python中):

x = [1,2,3,5,6,7]
y = [3,5,76,8,96,1]
data = [go.Bar(
    x=x,
    y=y
)]
layout = {
   'xaxis': {'title': 'Query Duration'},
   'yaxis': {'title': 'Proportion (%)'},
   'barmode': 'relative'
}

But as I tested, I couldn't send range to the data or layout.

但是在我测试时,我无法向数据或布局发送范围。

1 个解决方案

#1


0  

You can define the layout like so. The range property of xaxis or yaxis can be used for this.

您可以像这样定义布局。可以使用xaxis或yaxis的range属性。

range (array)
Sets the range of this axis. If the axis type is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). If the axis type is "date", it should be date strings, like date data, though Date objects and unix milliseconds will be accepted and converted to strings. If the axis type is "category", it should be numbers, using the scale where each category is assigned a serial number from zero in the order it appears. Each object has one or more of the keys listed below.

range(array)设置此轴的范围。如果轴类型为“log”,则必须记录所需范围的日志(例如,将范围设置为1到100,将范围设置为0到2)。如果轴类型是“日期”,它应该是日期字符串,如日期数据,但是Date对象和unix毫秒将被接受并转换为字符串。如果轴类型是“类别”,则它应该是数字,使用比例,其中每个类别按其显示的顺序从零开始分配序列号。每个对象都有一个或多个下面列出的键。

Check the official documentation also.

还请查看官方文档。

x = [1,2,3,5,6,7]
y = [3,5,76,8,96,1]
data = [go.Bar(
    x=x,
    y=y
)]
layout = {
   'xaxis': {'title': 'Query Duration', 'range': [1, 10]},
   'yaxis': {'title': 'Proportion (%)'}, 'range': [1, 100]},
   'barmode': 'relative'
}

#1


0  

You can define the layout like so. The range property of xaxis or yaxis can be used for this.

您可以像这样定义布局。可以使用xaxis或yaxis的range属性。

range (array)
Sets the range of this axis. If the axis type is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). If the axis type is "date", it should be date strings, like date data, though Date objects and unix milliseconds will be accepted and converted to strings. If the axis type is "category", it should be numbers, using the scale where each category is assigned a serial number from zero in the order it appears. Each object has one or more of the keys listed below.

range(array)设置此轴的范围。如果轴类型为“log”,则必须记录所需范围的日志(例如,将范围设置为1到100,将范围设置为0到2)。如果轴类型是“日期”,它应该是日期字符串,如日期数据,但是Date对象和unix毫秒将被接受并转换为字符串。如果轴类型是“类别”,则它应该是数字,使用比例,其中每个类别按其显示的顺序从零开始分配序列号。每个对象都有一个或多个下面列出的键。

Check the official documentation also.

还请查看官方文档。

x = [1,2,3,5,6,7]
y = [3,5,76,8,96,1]
data = [go.Bar(
    x=x,
    y=y
)]
layout = {
   'xaxis': {'title': 'Query Duration', 'range': [1, 10]},
   'yaxis': {'title': 'Proportion (%)'}, 'range': [1, 100]},
   'barmode': 'relative'
}