简体   繁体   English

Python:在画布中设置轴比例

[英]Python: set axis scale in canvas

In Python, using the canvas module, how do I make a canvas in which the x-axis starts at 0?在 Python 中,使用 canvas 模块,如何制作 x 轴从 0 开始的画布? I can make a script which draws the gridlines at 0, but the actual canvas still goes from -10 to 10我可以制作一个在 0 处绘制网格线的脚本,但实际画布仍然从 -10 变为 10

I'm talking about an asymetrical layout here.我在这里谈论的是不对称布局。 I can set the minimum x to be 0, but that only works if the maximum x is 0 as well.我可以将最小 x 设置为 0,但这仅在最大 x 也为 0 时才有效。 What I'm trying to do is making a graph in [0, 10]我想要做的是在 [0, 10] 中制作图表

If you look at the code , you'll see that the the __init__ function takes a parameter xrange , which is used to set the limits of the x-axis.如果您查看代码,您会看到__init__函数接受一个参数xrange ,该参数用于设置 x 轴的限制。 Just initialize your object with the range you need:只需使用您需要的范围初始化您的对象:

c = Canvas(xrange=(0, 10))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM