0

I'm plotting a multiplot in GNUPLOT and in order to save space, I only plot the axis labels on one of the plots. For the other plots, I overwrite the tics-labels using

set ytics ("" -20, "" -15, "" -10, "" -5, "" 0, "" 5, "" 10, "" 15, "" 20)

For a small scale like this, its doable manually. Can I use a gnuplot built-in (for-loop) to dynamically write this "range"?

2 Answers 2

3

Yes, you can, with something like

numtics = 8

set macros

ticstring = '('

do for [i=0:numtics] {
    ticstring = ticstring.'"" '.(-20 + i*5).', '
}

ticstring = ticstring.'"" 20)'

set ytics @ticstring

What may be simpler in your case would be the command

set ytics format "" 5

Which will put a tic every 5 with a blank label.

Sign up to request clarification or add additional context in comments.

1 Comment

my example is just a simply case to illustrate the idea.
2

I think that it is MUCH easier to just do something like:

set multiplot layout 1,2

set xtics format ""   #no x-tic labels on the top plot
plot sin(x)           #top plot

set xtics format "%g" #x-tic labels on the bottom plot
plot cos(x)           #bottom plot

unset multiplot

1 Comment

That's indeed a good point. My question is in part aimed at understanding how the for-loop works in gnuplot and I required a real-life example for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.