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

Dynamically setting mxtics between two xtics

525 views
Skip to first unread message

Satish Thareja

unread,
Jan 12, 2012, 2:06:40 AM1/12/12
to
I am trying to plot data samples via gnuplot( ver. 4.2.2).
The data is collected with a frequency of 10 minutes and the graphs
are generated dynamically after every data collection process.
Gnuplot automatically adds xtics on the graph, but I am confused on
how does it decide what interval to use.eg:
1. For smaller intervals xtics are positioned at 1 hour, 2 hour
intervals
2. For data spanning from 1 to 5 days xtics are positioned at 12 hour
intervals
3. For Further ahead xtics are positioned at 24 hour intervals

The problem comes when when we want to visualize the data using the
mxtics( minor xtics ), I am not able to decide the number of mxtics to
be inserted between two xtics.

In concise, is there a way so that mxtics are drawn on the graph for
every data sample ( either as an option in gnuplot OR some way to find
out the interval between the xtics to set the mxtics appropriately).

Hans-Bernhard Bröker

unread,
Jan 12, 2012, 1:46:00 PM1/12/12
to
On 12.01.2012 08:06, Satish Thareja wrote:

> In concise, is there a way so that mxtics are drawn on the graph for
> every data sample ( either as an option in gnuplot OR some way to find
> out the interval between the xtics to set the mxtics appropriately).

No. Nor should there IMHO ever be such an option. The x positions of
your data samples are already displayed as the x positions of the actual
data. Putting extra, unlabelled markers at the same x positions serves
no useful purpose.

sfeam

unread,
Jan 12, 2012, 4:01:18 PM1/12/12
to
Placing a tic mark on the axis for every data point in the graph is
called a "rug plot" or "rug graph" in other plotting packages.

Gnuplot does not offer this as an separate plotting style, but you can
achieve the same effect by using, for example

plot 'foo' using 1 : 2 : xticlabels("") : yticlabels("")

However this is not precisely what you asked for, since it sets the
xtics and ytics rather than xmtics and ymtics.

Ingo Thies

unread,
Jan 13, 2012, 4:50:46 AM1/13/12
to
On 12.01.2012 08:06, Satish Thareja wrote:

> In concise, is there a way so that mxtics are drawn on the graph for
> every data sample ( either as an option in gnuplot OR some way to find
> out the interval between the xtics to set the mxtics appropriately).

I am trying to understand what you want to do: You are asking for
separate mxtics scales for each sample, or an mxtic for each data point?

Both should be possible with some external processing and then writing
the tics as arrows where ever you want. A similar thing has been done in
this plot on Wikipedia (although it might have been made with a special
software):

http://upload.wikimedia.org/wikipedia/commons/b/ba/PlanckianLocus.png

Here, the oblique tics and mtics of the color temperature must have been
made by lines with given slopes, and I succeeded to reproduce a similar
plot with gnuplot using arrows.

Your task sounds much simpler since you only need vertical small arrows
placed on the x axis or some parallel axis, and positions defined by
your data. I have also written some algorithm to estimate the
appropriate number of partitions of the tics intervals. As an example:
If the xrange has a width of 10 units, than one might want xtics at 0,
2, 4..., and set mtics 4 (i.e. at 0.5 intervals), but if xscale covers
20, then xtics at 5-intervals and mtics at 1,0-intervals (i.e. set mtics
5) might look better. The algorithm outputs a gnuplot code fragment that
contains the set *tics, set m*tics statements and can be loaded by a
driver script. Two axes could be set this way using both x and x2 axis,
but more than two simultaneous x axes, or tics positioned in some
irregular way (see the color space plot above) would require them to be
drawn as arrows.

If you mean something entirely different, could you please give an
example (maybe ASCII drawing or even a scanned hand drawing or so)?

HTH,

Ingo

scanty

unread,
Jan 18, 2012, 8:12:50 AM1/18/12
to
Hi Ingo,

What I want is a mxtic for each data point.
I am not able to figure out how to gnuplot decides the interval of a
xtic.
Can you please share the way to figure out the same.

Thanks,
Satish

Ingo Thies

unread,
Jan 18, 2012, 12:25:19 PM1/18/12
to
Hi!

> What I want is a mxtic for each data point.
> I am not able to figure out how to gnuplot decides the interval of a
> xtic.
> Can you please share the way to figure out the same.

In this case, I only see the way via arrows. If you have written by
yourself the program that generates the data, then you can include an
output statement to a file that generates lines like

set arrow iarr from xpos,y0 to xpos,y1 nohead

where xpos is the x value of your data point, y0 is the lower y-border
displayed in your graph, and y1 is y0 plus some length.

Another possibility might be to fake tics by using points of type 1
(i.e. crosses) of appropriate size, but this would generate tics in both
directions away from the x-axis. But it could be done inside a gnuplot
script, where you take the x value directly and replace the y value with
the minimum y.

I know, these are more or less dirty hacks, but the former one really
works nicely, and even allows slanted irregular tics (remember the
Planck locus in the color space plot from Wikipedia).

Another hack that might work uses manually set tics using

set xtics ("<label1>" <x1>, "<label2>" <x2>,...)

where "label" stands for any string (in your case maybe just blank), and
x1,x2... stands for your x positions. This, however, would probably
again require some modifications to your data-generating program. Maybe
it could also be done with some awk script, but I am not an expert on
this. If you also want regularly labelled major xtics at the same time
you have to use x2tics instead and set x2range to the same borders as
xrange. I have not yet looked up, but maybe you can set xtics and x2tics
to different styles (i.e. lengths), so that the manually set xtics
appear like minor tics, while the major x2tics have normal size.

In my opinion, the program-generated "set arrow" statements are the
least painful way to do this.

HTH,

Ingo

ab

unread,
Jan 19, 2012, 3:43:07 AM1/19/12
to
Hi,

>
> > What I want is a mxtic for each data point.
> > I am not able to figure out how to gnuplot decides the interval of a

can't you just use

plot "test.dat" u 1:(0.2) w impulses

this will draw a line from the x-axis to 0.2 for each data point.

scanty

unread,
Jan 23, 2012, 6:38:08 AM1/23/12
to
@Ingo: the arrows work fine, but the length of arrows is creating a
problem as the range of data samples varies between 10-50000.

@ab: The impulses are working fine, but gnuplot is creating a key
( legend ) entry for the impulses.
While key entry for other plots is required( and set by autotitle
columnhead) , can we do something so that the key entry for impulses
is not displayed.

Ingo Thies

unread,
Jan 23, 2012, 10:25:24 AM1/23/12
to
On 23.01.2012 12:38, scanty wrote:

> @Ingo: the arrows work fine, but the length of arrows is creating a
> problem as the range of data samples varies between 10-50000.

But the yrange is constant for each plot (i.e. a standard rectangular
coordinate system, unlike the Planck curve example), so you can adjust
the start point and the length of the arrows to an appropriate value.

> @ab: The impulses are working fine, but gnuplot is creating a key
> ( legend ) entry for the impulses.

Yo can add a notitle statement in the plot:

plot <thefile> using <...> notitle with impulses

This omits the key entry.

> While key entry for other plots is required( and set by autotitle
> columnhead) , can we do something so that the key entry for impulses
> is not displayed.

HTH,

Ingo

0 new messages