0
votes

I am try to plot a graph in GNUPLOT which has both positive/negative values. It is plotting in 1st quadrant.I mean x axis start from some negative value, same with y axis. I want to plot on both sides, like we see a 4 quadrants. Like in middle should be 0, on left negative values and on right positive value, for both x and y axis. Please help. Thanks in advance.

1
Welcome to StackOverflow! What have you tried so far? Have you checked the gnuplot help and/or the gnuplot homepage? Have you done a web search? How does your ("non-working") code look like? - theozh
any feedback? Any response would be appreciated. - theozh

1 Answers

1
votes

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. You can get help for almost every keyword via typing help <keyword> in the gnuplot console, e.g. help xtics, help zeroaxis, help border, etc.

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:

enter image description here