Plot a straight line, parallell to the y-axis in gnuplot?

• Dr-NiKoN
In summary, to plot a straight line parallel to the y-axis in Gnuplot, you can use the command 'plot 20' where x=20. To learn more about plotting, try the command 'help plot'. If this doesn't work, you can try using the command 'set parametric' followed by 'plot 20,t' to plot a line parallel to the x-axis. If you need a longer line, you can adjust the range of t. To get Gnuplot for Windows, you can use the environment Cygwin to build Unix applications, including Gnuplot. Alternatively, you can download a Win32 package from the Gnuplot SF site, but you may need additional dependencies.
Dr-NiKoN
How do you plot a straight line, parallell to the y-axis in gnuplot?
Something like:
x = 20
?

plot 20, gives y = 20, a line parallell with the x-axis.

I want x = 20

Try this:

'set parametric'
'plot 20,t'

Hm, that gives me a short line, it stops at around y = 5. I need it all the way up since I'm plotting linear unequalities.

'plot [t=-1000:1000] 20,t'

Just change the t-range to whatever fits for you.

Ah, perfect.

Thanks a lot :)

Looks like you've gotten the other problem of the linear programming thing figured out. ;)

hehe, yup :)

can I get Gnuplot for windows?

Yes, you can, but there's a catch. Gnuplot is primarily for Unix systems, however, an environment does exist for Win32 called Cygwin that will enable you to build Unix applications, such as Gnuplot.

You can get Cygwin (be sure to read the documentation) from:

http://www.cygwin.com

Once you have Cygwin installed, grab the Unix sources from:

http://www.gnuplot.info

Gnuplot's primary graphics environment is X11 - you'll have to install XFree86 in the Cygwin distribution. If you feel this is too complex for your tastes, Gnuplot can generate PDF and Postscript plots.

Edit: I found this nice link on Gnuplot SF site:

http://sourceforge.net/project/showfiles.php?group_id=2055&package_id=1996

There are some Win32 packages, but you might have to have the Cygwin .dll or some more dependencies that are present in the Cygwin distribution. This will save you from building Gnuplot, regardless.

Last edited by a moderator:

1. How do I plot a straight line in gnuplot?

To plot a straight line in gnuplot, you can use the plot command with the linestyle option set to 0. This will create a line with no markers or symbols.

2. How do I make the line parallel to the y-axis?

In order to make the line parallel to the y-axis, you can specify a constant x-value for all the data points. For example, if you want to plot a line at x=2, your data file should contain two columns: the first column with the x-values (all 2s) and the second column with the y-values.

3. Can I change the color of the line?

Yes, you can change the color of the line by using the linecolor option in the plot command. You can specify a color name, RGB values, or a hex code to customize the color of the line.

4. Can I add labels and a title to the plot?

Yes, you can add labels and a title to the plot by using the set xlabel, set ylabel, and set title commands. These commands allow you to customize the labels and title for your plot.

5. How can I save the plot as an image file?

You can save the plot as an image file by using the set term and set output commands. You can specify the file format (e.g. png, jpeg) and the file name in the set term command, and then use the set output command to save the plot as an image file with the specified name.

• Computing and Technology
Replies
2
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
835
• Precalculus Mathematics Homework Help
Replies
17
Views
1K
• Computing and Technology
Replies
5
Views
16K
• Set Theory, Logic, Probability, Statistics
Replies
11
Views
1K
• Nuclear Engineering
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
876
• Programming and Computer Science
Replies
4
Views
3K
• Programming and Computer Science
Replies
3
Views
4K