2
votes

I have two data sets x,y, x1,y1. I want to plot them all in one figure.

require 'gnuplot'

local x,y,x1,y1 = unpack(data)
gnuplot.xlabel('PPL')
gnuplot.ylabel('Epoch #')
gnuplot.plot({x,y},{x1,y1})

enter image description here

This works well, but I'd like to have straight lines instead of dotted lines. Also, I want to include a legend in top right corner. Alas, whatever combination I tried, it does not work.

gnuplot.plot({x,y},{x1,y1},'-')
gnuplot.plot('1','2',{x,y},{x1,y1},'-')
gnuplot.plot({'1','2',{x,y},{x1,y1},'-'})

How can I plot two lines and add a legend in one figure with gnuplot?

2

2 Answers

0
votes

According to the docs the following should work:

gnuplot.plot({'first', x, y, '-'}, 
    {'second', x1, y1, '-'})
0
votes

torchstyle variable contains: "set style data linespoints", which sets the style that data are plotted to linespoints.

You need to write this command:

gnuplot.raw('set style data lines')