简体   繁体   English

Gadfly 中横轴的范围

[英]The range of horizontal axis in Gadfly

I use the following code to produce a graph in Julia with Gadfly:我使用以下代码在 Julia 中使用 Gadfly 生成图形:

using Gadfly, Cairo, Fontconfig
p = plot(sin, 0, pi)
p |> PNG("sin_pi.png", 6inch, 4inch)

This is the graph that I get:这是我得到的图表:

正弦

The horizontal axis is not adjusted properly since there is a blank space at the end.横轴未正确调整,因为末尾有空格。 However, if the indicated bounds of the horizontal axis are integers, there is no blank space.但是,如果水平轴的指示边界是整数,则没有空格。 Consider the following example:考虑以下示例:

using Gadfly, Cairo, Fontconfig
p = plot(sin, 0, 4)
p |> PNG("sin_4.png", 6inch, 4inch)

在此处输入图片说明

I would guess that this is simply a bug, but I am completely new to Julia and Gadfly so I do not know if this is the intended behaviour.我猜这只是一个错误,但我对 Julia 和 Gadfly 完全陌生,所以我不知道这是否是预期的行为。 Is this a bug or is there a way to adjust how the range of the horizontal axis is determined?这是一个错误还是有办法调整水平轴的范围是如何确定的?

Any help is much appreciated!任何帮助深表感谢!

PS I use Julia v1.3.1 with Gadfly v1.2.0 on macOS 10.15.3. PS 我在 macOS 10.15.3 上使用 Julia v1.3.1 和 Gadfly v1.2.0。 The results are the same if I just use如果我只是使用,结果是一样的

using Gadfly
plot(sin, 0, pi)
plot(sin, 0, 4)

but I am not sure if there is an easy way to incorporate an SVG file into my question.但我不确定是否有一种简单的方法可以将 SVG 文件合并到我的问题中。

Gadfly 文档中有一个示例: http : //gadflyjl.org/stable/gallery/coordinates/

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

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