Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

user defined xtics and mxtics

3,149 views
Skip to first unread message

Fab

unread,
Oct 23, 2012, 4:03:03 PM10/23/12
to
Dear All

I read in the Gnuplot info's, that when I define my own xtics, I can not
use mxtics, which makes sense. However, especially in LaTeX terminals,
it is sometimes needed to redefine the axis label (actually only the
label and not the tics). Is it somehow possible to define xtics and
mxtics the usual way but then change only the axis label, leaving the
tics as they are? E.g., in Matlab you have two arrays defining the
tics, one with the numeric data and the other with the label strings.

Thanks!
Fab

sfeam

unread,
Oct 23, 2012, 6:02:32 PM10/23/12
to
Fab wrote:

> Dear All
>
> I read in the Gnuplot info's, that when I define my own xtics, I can not
> use mxtics, which makes sense.

That's not quite right. You can define both tics and mtics manually.
But you cannot define tics and have the program insert mtics automatically
between them.

> However, especially in LaTeX terminals,
> it is sometimes needed to redefine the axis label (actually only the
> label and not the tics). Is it somehow possible to define xtics and
> mxtics the usual way but then change only the axis label, leaving the
> tics as they are?

Certainly.
set xtics ("One" 1, "Two" 2, "Three" 3)
set xlabel "My favorite label"

But maybe you are asking something else?
For LaTeX output you often want to set a LaTeX format for the tic labels:
set xtics format "$%g$"

> E.g., in Matlab you have two arrays defining the
> tics, one with the numeric data and the other with the label strings.

That is also possible, so long as both arrays can be read from the
same file:

plot <my-real-plot>, 'labeldata' using 1:xticlabels(2)

where the file labeldata contains
1 "One"
2 "Two"
3 "Three"
...


Fab

unread,
Oct 24, 2012, 1:15:36 AM10/24/12
to
sfeam <sf...@users.sourceforge.net> writes:

> Fab wrote:
>
>> Dear All
>>
>> I read in the Gnuplot info's, that when I define my own xtics, I can not
>> use mxtics, which makes sense.
>
> That's not quite right. You can define both tics and mtics manually.
> But you cannot define tics and have the program insert mtics automatically
> between them.
>
Indeed, I was not precise here!

>> However, especially in LaTeX terminals,
>> it is sometimes needed to redefine the axis label (actually only the
>> label and not the tics). Is it somehow possible to define xtics and
>> mxtics the usual way but then change only the axis label, leaving the
>> tics as they are?
>
> Certainly.
> set xtics ("One" 1, "Two" 2, "Three" 3)
> set xlabel "My favorite label"
>
> But maybe you are asking something else?
> For LaTeX output you often want to set a LaTeX format for the tic labels:
> set xtics format "$%g$"
>
My problem is the following: I have a plot with log x-axis. When I use
the format specifier for scientific notation, LaTeX will typeset this as
such (with the e-01, etc. notation). However, I would like to have xtic
labels like $10^{-1}$, hence I set them manually. But, for a log plot I
would also like the minor xtics to indicate the scale between the
decades. But I can not use xmtics in this case. Do I also have to
create an array for the minor xtics? I would like to have the xmtics
with half the ticlength of the major xtics. How would you do it?

>> E.g., in Matlab you have two arrays defining the
>> tics, one with the numeric data and the other with the label strings.
>
> That is also possible, so long as both arrays can be read from the
> same file:
>
> plot <my-real-plot>, 'labeldata' using 1:xticlabels(2)
>
> where the file labeldata contains
> 1 "One"
> 2 "Two"
> 3 "Three"
> ...

Thanks for this input!

Regards,
Fab

sfeam

unread,
Oct 24, 2012, 2:05:08 AM10/24/12
to
set format '$ %.2t10^{%T}$'

> , hence I set them manually. But, for a log plot
> I would also like the minor xtics to indicate the scale between the
> decades. But I can not use xmtics in this case. Do I also have to
> create an array for the minor xtics? I would like to have the xmtics
> with half the ticlength of the major xtics. How would you do it?

set tics scale 1.0, 0.5


Fab

unread,
Oct 24, 2012, 7:16:10 AM10/24/12
to
elegant! Thanks

Best,
Fab

Ingo Thies

unread,
Oct 24, 2012, 4:24:54 PM10/24/12
to
sfeam wrote:

> That's not quite right. You can define both tics and mtics manually.
> But you cannot define tics and have the program insert mtics automatically
> between them.

Does gnuplot now really support manually defined tics and mtics?

> Certainly.
> set xtics ("One" 1, "Two" 2, "Three" 3)

So, how do you define the manual mtics here? As far as I remember, this
has not been possible until recently (unless you use arrows for this, of
course).

Best wishes,
Ingo

sfeam

unread,
Oct 24, 2012, 8:23:40 PM10/24/12
to
Ingo Thies wrote:

> sfeam wrote:
>
>> That's not quite right. You can define both tics and mtics manually.
>> But you cannot define tics and have the program insert mtics
>> automatically between them.
>
> Does gnuplot now really support manually defined tics and mtics?
>

So far as I know it has always been possible to define minor tics.
However, no associated text label is drawn for the minor tics.

> So, how do you define the manual mtics here? As far as I remember, this
> has not been possible until recently (unless you use arrows for this, of
> course).

Labeled major tics at 0, 0.5, 1.0, unlabeled minor tics at 0.25 and 0.75:

set xtics ("Zero" 0 0, "Half" 0.5 0, "One" 1.0 0, 0.25 1, 0.75 1)

The form for each tic is ("Label" <position> <level>)
where level 0 is major tic, and 1 is minor tic.
Both the label and the level are optional.

Levels > 1 are currently treated exactly the same as level=1
(label is not printed, minor tic is drawn) but in the future may have
some different treatment.

Ethan






>
> Best wishes,
> Ingo

Cristian Camilo Mejia

unread,
Apr 23, 2013, 5:04:35 PM4/23/13
to

Cristian Camilo Mejia

unread,
Apr 23, 2013, 5:07:13 PM4/23/13
to
Dear all,

I can't show the minor tics with the following script; however if I comment the lines for xtics and ytics the minor tics appears without problem.

Thanks in advance for any help,

Crist.


set term postscript eps color enhanced font "Times-Roman" 23
set output "matrix.eps"

set palette defined (\
1 '#0025ad', \
2 '#0042ad', \
3 '#0060ad', \
4 '#007cad', \
5 '#0099ad', \
6 '#00ada4', \
7 '#00ad88', \
8 '#00ad6b', \
9 '#00ad4e', \
10 '#00ad31', \
11 '#00ad14', \
12 '#09ad00' \
)


set pm3d map
#set pm3d interpolate 2,2

##############
set mxtics 4
set mytics 3
set xtics ("8.36" 0,"8.389" 30, "8.42" 60) font "Times-Roman, 23"
set ytics ("1" 0,"0.75" 25,"0.5" 50,"0.25" 75, "0" 100) font "Times-Roman, 23"
set cbtics ("1" -0.0316022150218487,"0.5" -0.0316060110926628,"0" -0.0316098071634769)font "Times-Roman, 23"
#############


set xlabel 'P' offset 0,0 font "Times-Italic,23" left rotate by 0
set ylabel 'X_{cm}' offset 0,0 font "Times-Italic,23" left rotate by 0

splot 'myfile.txt' matrix
#print 'Maximum = ',GPVAL_DATA_Z_MAX
#print 'Minimum = ',GPVAL_DATA_Z_MIN
0 new messages