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

Combining splot and plot

1,102 views
Skip to first unread message

phanlipo

unread,
May 10, 2017, 8:56:36 AM5/10/17
to
Dear all,

I would combine a splot of a matrix as a image with a normal plotted function.

My datafile 'Matrix.dat' has following content:

___________
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
___________

And I'm plotting with following commands:

___________
set terminal postscript portrait enhanced clip color "Helvetica" 15

set encoding utf8

set size square

set output 'Spektrum.ps'

set view map

set yrange [-0.5:4.5]
set xrange [-0.5:4.5]

set palette rgbformulae 22,13,-36

splot 'Matrix.dat' matrix using 2:1:3 w image

plot x with lines
___________

A replot does not solve my problem. I would combine the two plots in one graphic.

Best,
phanlipo

Karl Ratzsch

unread,
May 10, 2017, 10:50:13 AM5/10/17
to
Am 10.05.2017 um 14:56 schrieb phanlipo:

> I would combine a splot of a matrix as a image with a normal plotted function.


You mean next to each other or an inset or similar?

You can make additional, totally independent plots (2D or 3D) to the
same canvas, check "help multiplot". For a simple case, use the "layout"
option, or control the position of the (s)plots individually via "set
size", "set origin" and/or "set margins".


Combining 2D and 3D in the same plot (=same coordinate system) is not
directly possible, obviously. Either use splot for the 2D plot, too, or
use again multiplot and transform the coordinate systems by hand, so
they land exactly on top of each other.

hth

Karl

phanlipo

unread,
May 10, 2017, 11:55:35 AM5/10/17
to
Thank you, I've used multiplot and it looks good. The plots should be combined in the same plot.

____________________________
#!/usr/bin/gnuplot

set terminal postscript portrait enhanced clip color "Helvetica" 15

set encoding utf8

set size square

set output 'Spektrum.ps'

set view map

set yrange [-0.5:4.5]
set xrange [-0.5:4.5]

set palette rgbformulae 22,13,-36

set multiplot

splot 'Matrix.dat' matrix using 2:1:3 w image

unset key
unset xtics
unset ytics
unset border

set size 0.835,0.835
set origin 0.088,0.093

plot x with lines

unset multiplot
__________________________

Karl Ratzsch

unread,
May 10, 2017, 2:50:35 PM5/10/17
to
Am 10.05.2017 um 17:55 schrieb phanlipo:
>
> Thank you, I've used multiplot and it looks good. The plots should be combined in the same plot.

> set view map
>
> set multiplot
>
> splot 'Matrix.dat' matrix using 2:1:3 w image
>
> plot x ....

Ah, you want combine the 2D projection of a 3D plot with another 2D
plot. That wasn't clear from your original posting.

It would be nice if you could just directly "replot" here, which is
what you originally tried, i guess.


Gavin Buxton

unread,
May 11, 2017, 4:50:41 PM5/11/17
to
Sounds like you got it sorted. As someone who's been in the same situation, I've usually resolved it by making the 2D plot into a 3D plot. For example, I recently had this problem trying to add a vector plot to a contour plot. The benefit of doing it this way is that the axis all align OK, otherwise you have to mess around with things like size and origin.
0 new messages