简体   繁体   English

在 GNUPLOT 中使用正值/负值进行绘图

[英]Plotting in GNUPLOT with both positive/negative values

I am try to plot a graph in GNUPLOT which has both positive/negative values.我正在尝试 plot GNUPLOT 中的图形,它具有正值/负值。 It is plotting in 1st quadrant.I mean x axis start from some negative value, same with y axis.它在第一象限绘制。我的意思是 x 轴从某个负值开始,与 y 轴相同。 I want to plot on both sides, like we see a 4 quadrants.我想要 plot 在两边,就像我们看到的 4 个象限。 Like in middle should be 0, on left negative values and on right positive value, for both x and y axis.对于 x 轴和 y 轴,中间应该为 0,左边为负值,右边为正值。 Please help.请帮忙。 Thanks in advance.提前致谢。

Please make sure that you've done a reasonable search before asking.在询问之前,请确保您已经进行了合理的搜索。 There are a lot of examples around.周围有很多例子。 Although, sometimes it might not be easy to find the exact graph configuration you are looking for.虽然,有时可能不容易找到您正在寻找的确切图形配置。 Basically, everything is in the manual, although it can be confusing for a gnuplot beginner.基本上,一切都在手册中,尽管它可能会让 gnuplot 初学者感到困惑。 You can get help for almost every keyword via typing help <keyword> in the gnuplot console, eg help xtics , help zeroaxis , help border , etc.您可以通过在 gnuplot 控制台中键入help <keyword>获得几乎每个关键字的帮助,例如help xticshelp zeroaxishelp border等。

If I understood your question correctly, you are probably looking for something like this:如果我正确理解你的问题,你可能正在寻找这样的东西:

Code:代码:

### plot a function in a 4-quadrant graph 
reset session

set size square
set xrange[-10:10]
set yrange[-10:10]

set border 0
set xzeroaxis lt -1
set yzeroaxis lt -1

set xtics axis nomirror
set ytics axis nomirror
set mxtics 5
set mytics 5
set grid x y mx my
set xtic add ('' 0)     # remove 0 from xtics
set ytic add ('' 0)     # remove 0 from ytics
set key top left

f(x) = 0.02*x**3 - 0.5*x

plot f(x) w l lc "red"
### end of code

Result:结果:

在此处输入图像描述

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

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