The following code creates a plot. My question is: how can one create those two lines using different styles without putting them in a data file and using plot 'plotting_data.dat' index 0 with linespoints linestyle 1, '' index 1 with linespoints linestyle 2
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
set style line 2 \
linecolor rgb '#dd181f' \
linetype 1 linewidth 2 \
pointtype 5 pointsize 1.5
# THIS WON'T WORK
# plot '-' index 0 with linespoints linestyle 1, \
# '-' index 1 with linespoints linestyle 2
# THIS CREATES A PLOT
plot '-' with linespoints linestyle 1
# First data block (index 0)
# X Y
1 2
2 3
# Second index block (index 1)
# X Y
3 2
4 1
Thanks in advance.
You don't specify if you absolutely need to plot your data via '-'
.
If you want two plots with data via '-'
you have to provide the data twice. Check help data
.
There is another way to "deliver" data together with the gnuplot code by defining datablocks. Check help datablocks
.
### data in code included
reset session
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
set style line 2 \
linecolor rgb '#dd181f' \
linetype 1 linewidth 2 \
pointtype 5 pointsize 1.5
$Data <<EOD
# First data block (index 0)
# X Y
1 2
2 3
# Second index block (index 1)
# X Y
3 2
4 1
EOD
plot $Data index 0 with linespoints linestyle 1, \
$Data index 1 with linespoints linestyle 2
### end of code