This is my attempt at making the xtics label color match the line color in a box plot in gnuplot:
$DATA << EOD
1 1
2 2
3 3
EOD
set linetype 1 linecolor rgb "red"
set linetype 2 linecolor rgb "green"
set linetype 3 linecolor rgb "blue"
set key off
set boxwidth 0.5
set style fill solid 0.5
set xrange [0:4]
set yrange [0:4]
set xtics ("1" 1) textcolor rgb "red"
set xtics add ("2" 2) textcolor rgb "green"
set xtics add ("3" 3) textcolor rgb "blue"
plot $DATA using 1:2:1 with boxes linecolor variable
But it does not work:
Any idea? Thanks!
I'm not sure whether you can set xtics individually in different colors. So, the following solution sets the xtics as empty lines and you plot your xtics with labels with a certain offset. The disadvantage is that you have to set the y-position here: (0) with offset 0,-1. I hope there are better solutions.
Code:
### "xtic labels" in different colors
reset session
$Data << EOD
1 1
2 2
3 3
EOD
set linetype 1 lc "red"
set linetype 2 lc "green"
set linetype 3 lc "blue"
set key off
set boxwidth 0.5
set style fill solid 0.5
set xrange [0:4]
set yrange [0:4]
set format x "\n" # xtic label empty line
plot $Data u 1:2:1 w boxes lc var, \
'' u 1:(0):1:1 w labels tc var offset 0,-1
### end of code
Alternatively, you could use an offset relative to the graph:
plot $Data u 1:2:1 w boxes lc var, \
'' u 1:(0):1:1 w labels tc var offset 0, graph -0.05
Result:
Am using gnuplot 5.0. with the following as pereamble to each script:
set terminal epslatex 8 color standalone colortext
The issue is that gnuplot is skipping the first row. To my knowledge 4.6 version addressed a similar issue.
Any idea on the problem please?
Example of data file points.dat
4 4
4 -4
-4 4
-4 -4
The first line (4, 4) is skipped. So instead of four points, only three are displayed by gnuplot. Herewith the command am using
#!/bin/bash
set terminal epslatex 8 color standalone colortext
set output outputFileName
set size .55,.55
set pointsize 3.0
##############
# Line styles
##############
set linestyle 1 lt 5 lw 1 #
set linestyle 2 lt 2 lw 1.5
set linestyle 3 lt 6 lw 1 #
set linestyle 4 lt 3 lw 1
set linestyle 5 lt 2 lw 2 #
set linestyle 6 lt 1 lw 2
##################
# Titles
##################
set title 'Image'
set xlabel '$x$' offset 0,0.5
set ylabel '$y$' offset 2,0
set macros
filename_init = sprintf("%s/image_init.dat",dataFileDirectory)
set key autotitle columnhead
set key horiz
set multiplot
plot
filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" notitle 'initial'
On trick to bypass the issue is to duplicate the first row. Bu this is not practical.
With set key autotitle columnheader gnuplot uses the entries in the first row as key entries, even though for the plot you have specified notitle.
To demonstrate this, consider the following script, using the four data points in points.dat, which you posted:
set terminal pngcairo
set output 'foobar.png'
set offsets 1,1,1,1
set key autotitle columnhead
filename_init = 'points.dat'
set multiplot layout 1,2
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta"
set key noautotitle
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" title 'initial'
unset multiplot
The result is
So, just remove the line set key autotitle columnhead from your script, and use plot ... title 'initial'. That gives you the expected result.
Am using gnuplot 5.0. with the following as pereamble to each script:
set terminal epslatex 8 color standalone colortext
The issue is that gnuplot is skipping the first row. To my knowledge 4.6 version addressed a similar issue.
Any idea on the problem please?
Example of data file points.dat
4 4
4 -4
-4 4
-4 -4
The first line (4, 4) is skipped. So instead of four points, only three are displayed by gnuplot. Herewith the command am using
#!/bin/bash
set terminal epslatex 8 color standalone colortext
set output outputFileName
set size .55,.55
set pointsize 3.0
##############
# Line styles
##############
set linestyle 1 lt 5 lw 1 #
set linestyle 2 lt 2 lw 1.5
set linestyle 3 lt 6 lw 1 #
set linestyle 4 lt 3 lw 1
set linestyle 5 lt 2 lw 2 #
set linestyle 6 lt 1 lw 2
##################
# Titles
##################
set title 'Image'
set xlabel '$x$' offset 0,0.5
set ylabel '$y$' offset 2,0
set macros
filename_init = sprintf("%s/image_init.dat",dataFileDirectory)
set key autotitle columnhead
set key horiz
set multiplot
plot
filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" notitle 'initial'
On trick to bypass the issue is to duplicate the first row. Bu this is not practical.
With set key autotitle columnheader gnuplot uses the entries in the first row as key entries, even though for the plot you have specified notitle.
To demonstrate this, consider the following script, using the four data points in points.dat, which you posted:
set terminal pngcairo
set output 'foobar.png'
set offsets 1,1,1,1
set key autotitle columnhead
filename_init = 'points.dat'
set multiplot layout 1,2
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta"
set key noautotitle
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" title 'initial'
unset multiplot
The result is
So, just remove the line set key autotitle columnhead from your script, and use plot ... title 'initial'. That gives you the expected result.
I'm ploting with gnuplot but in the 3D graphics some areas are not completed, empty.
The question is simple: how to force it to fill the empty areas ?
Commands that I'm using:
fit (a**-(x**(y**b))) './Tabela_perda_01_MOS_70ms_com_sameq_GOP_30_2_Foot.txt' using 1:2:3:(1) via a,b
set clabel '%8.2f'
set key right
set xlabel "X"
set ylabel "Y"
set zlabel "Z"
set xrange [0:1]
set yrange [2:20]
set zrange [0:1]
set isosample 11,20
set pointsize 0.5
set style line 1 lt 1 lw 2 pt 3 lc rgb "black"
set style line 2 lt 1 lw 1 pt 3 lc rgb "black"
splot "./Tabela_perda_01_MOS_70ms_com_sameq_GOP_30_2_Foot.txt" using 1:2:3 notitle w points ls 1, (a**-(x**(y**b))) w l ls 2
I have plotted two vectors (3,3,2), (2,2,1) and want to add an AABB to the first one
to show that the second vector is within the bounds of the first.
Adding set object rectangle from screen 0,0 to screen 3,3 front is not working.
So how can I draw the AABB (or a cuboid with a=3, b=3 and c=2)?
Also how can I put the the scale of the y-axis on the left side.
Still open:
Limit scale of y-axis to left side, and scale of x-axis to bottom front
Add arrows to x-, y- and z-axis
Delete the second x- and y- axis so that there is just one of each left
Gnuscript resource_vec_aabb
set xyplane 0
set grid
set xrange [0:5]
set yrange [0:5]
set zrange [0:5]
splot 'resource_vec_aabb.dat' with vectors filled head lw 2
Data resource_vec_aabb.dat
# Gnuplot .dat file for vectors
0 0 0 3 3 2
0 0 0 2 2 1
UPDATE
set termoption dashed #Needs to be set to draw dashed lines
set border 19 #To set axis (1 + 2 + 16). See: set border help
set xyplane 0
set grid
unset key
my_range = 4
set xrange [0:my_range]
set yrange [0:my_range]
set zrange [0:my_range]
set arrow from graph 0,0,0 to graph 1.05,0,0 size screen 0.025,15,60 \
filled ls 1 linecolor rgb "black"
set arrow from graph 0,0,0 to graph 0,1.05,0 size screen 0.025,15,60 \
filled ls 1 linecolor rgb "black"
set arrow from graph 0,0,0 to graph 0,0,1.05 size screen 0.025,15,60 \
filled ls 1 linecolor rgb "black"
set xtic 1
set ytic 1
set ztic 1
# AABB for 3,3,2
set arrow from 3,0,0 to 3,3,0 nohead linetype 2 linecolor rgb "green"
set arrow from 3,3,0 to 3,3,2 nohead linetype 2 linecolor rgb "green"
set arrow from 0,3,0 to 3,3,0 nohead linetype 2 linecolor rgb "green"
set arrow from 0,3,2 to 3,3,2 nohead linetype 2 linecolor rgb "green"
set arrow from 0,3,0 to 0,3,2 nohead linetype 2 linecolor rgb "green"
set arrow from 0,0,2 to 0,3,2 nohead linetype 2 linecolor rgb "green"
set arrow from 0,0,2 to 3,0,2 nohead linetype 2 linecolor rgb "green"
set arrow from 3,0,0 to 3,0,2 nohead linetype 2 linecolor rgb "green"
set arrow from 3,0,2 to 3,3,2 nohead linetype 2 linecolor rgb "green"
# 2,2,1
set arrow from 2,0,0 to 2,2,0 nohead linetype 2 linecolor rgb "blue"
set arrow from 0,2,0 to 2,2,0 nohead linetype 2 linecolor rgb "blue"
set arrow from 2,2,0 to 2,2,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 0,0,1 to 2,0,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 0,0,1 to 0,2,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 0,2,1 to 2,2,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 2,0,1 to 2,2,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 2,0,0 to 2,0,1 nohead linetype 2 linecolor rgb "blue"
set arrow from 0,2,0 to 0,2,1 nohead linetype 2 linecolor rgb "blue"
set view 40,44,1
splot 'resource_vec_aabb.dat' with vectors filled head lw 2
new output
Here is a suggestion to draw your bounding box with vectors and tic labels at the back y-axis. The bounding boxes are plotted instead of tediously drawn by arrows. There is still room for fine tuning.
Data: SO17363018.dat
# Gnuplot .dat file for vectors
0 0 0 3 3 2
0 0 0 2 2 1
Script: (works for gnuplot>= 4.6.0, March 2012)
### draw bounding box of vectors
reset
FILE = "SO17363018.dat"
set termoption dashed # required for gnuplot4.6 for dashed lines
set xlabel "x-axis" rotate parallel
set ylabel "y-axis" rotate parallel
set xyplane 0
set grid x,y
set xrange [0:5]
set yrange [0:5]
set border 19
set xtics 1 nomirror
set ytics axis
set for [i=1:3] arrow i from graph 0,0,0 to \
graph (1.12*(i==1)), (1.12*(i==2)), (1.12*(i==3)) \
size screen 0.025,15,60 filled ls 1 lc rgb "black"
x0(i,j,k) = ((i==0 ? 0 : i==1 ? k : j)*3+1)
y0(i,j,k) = ((i==0 ? j : i==1 ? 0 : k)*3+2)
z0(i,j,k) = ((i==0 ? k : i==1 ? j : 0)*3+3)
set key noautotitle
set view 61,49, 1.1
splot FILE u 1:2:3:($4-$1):($5-$2):($6-$3) w vec lc rgb "red" lw 2, \
for [c=0:1] for [i=0:2] for [j=0:1] for [k=0:1] FILE \
u (column(x0(i,j,k))):(column(y0(i,j,k))):(column(z0(i,j,k))): \
((i==0)*($4-$1)):((i==1)*($5-$2)):((i==2)*($6-$3)) \
every ::c::c w vec nohead ls 2 lw 1.5 lc c+2
### end of script
For current gnuplot versions 5.x, the script needs to be adapted slightly and you can be shorten the plot command a bit:
dashtype can be specified directly via dt 2, not via ls 2
one for loop less because in 4.6 lc variable doesn't seem to work together with ls 2.
splot FILE u 1:2:3:($4-$1):($5-$2):($6-$3) w vec lc rgb "red" lw 2, \
for [i=0:2] for [j=0:1] for [k=0:1] FILE \
u (column(x0(i,j,k))):(column(y0(i,j,k))):(column(z0(i,j,k))): \
((i==0)*($4-$1)):((i==1)*($5-$2)):((i==2)*($6-$3)):($0+1) \
w vec nohead lw 1.5 dt 2 lc var
Result: (created with gnuplot 4.6.0)