Gnuplot and adding function name to legend

In summary: Sure, we get acknowledged, but when the programs die your still out of luck and lay-offs occur. You go and find another position and go on. You never script yourself out of a job because no matter how much you do, your customer always wants more and they are in the business of getting as much out of you as they can for the money. You always have to check the contract deliverables and go by them, if they want extra they have to pay extra. In this day and age, expertise may keep you in a job, but if you are paid too well you are always on the top of the list to get laid off. I think that the key to success in this field is
  • #1
wellcaffeinated
4
0
Hi,
I've searched endlessly for an answer to this seemingly simple question, without success.
I am fitting a lot of data and I am plotting the data and the fit on the same graph. I would like to have gnuplot automatically add the function (with the values determined by the fit) to the legend. Doing this by hand would be very tedious. Any ideas would be appreciated.

thanks
 
Computer science news on Phys.org
  • #2
did you try

http://t16web.lanl.gov/Kawano/gnuplot/index-e.html

and the gnuplot site

http://www.gnuplot.info/

I have found both of these helpful
 
Last edited by a moderator:
  • #3
unfortunately yes :D
I have tried both of those references. thanks anyway.
Any other suggestions?
 
  • #4
Are you using a *nix box? If so, you could write a script to run the plot and curve fit, then extract teh correct variables out of the fit then put them back into the plot as the legend. Lot of work for something that you could do by hand for a few cases, but if you have many data sets to do it would be worth the effort.
 
  • #5
Yeah, I considered doing that. I figured for a program such as gnuplot, there would be some easy way of doing it. But it seems that is the only way.
oh well.
thanks
 
  • #6
Dr Transport said:
Are you using a *nix box? If so, you could write a script to run the plot and curve fit, then extract teh correct variables out of the fit then put them back into the plot as the legend. Lot of work for something that you could do by hand for a few cases, but if you have many data sets to do it would be worth the effort.

That's exactly what I had to do [via a perl script].
 
  • #7
robphy said:
That's exactly what I had to do [via a perl script].

When I was in grad school, I would spend hours plotting by hand every data set. When I got out and into industry, I started working a job where if I did that I still would be plotting my first test set. I had to learn how to script using sed & awk along with Korn shell. I once went on a range test, we took over 6 Gig of data (raw ascii file format) in two weeks of range time. It took me a week to write the script and get everything the way I wanted, 3 days to run all the plots ( somewhere in the neighborhood of 25K data sets). I figure I saved the company about two years worth of my salary spending the week learning how to script.
 
  • #8
Dr Transport said:
I figure I saved the company about two years worth of my salary spending the week learning how to script.

Hopefully, your efforts were acknowledged and rewarded. Don't just get paid for your time... also get paid for your expertise. However, one should be cautious about revealing all because, in some sense, you could script yourself out of a job.
 
  • #9
robphy said:
Hopefully, your efforts were acknowledged and rewarded. Don't just get paid for your time... also get paid for your expertise. However, one should be cautious about revealing all because, in some sense, you could script yourself out of a job.

Sure, we get acknowledged, but when the programs die your still out of luck and lay-offs occur. You go and find another position and go on. You never script yourself out of a job because no matter how much you do, your customer always wants more and they are in the business of getting as much out of you as they can for the money. You always have to check the contract deliverables and go by them, if they want extra they have to pay extra. In this day and age, expertise may keep you in a job, but if you are paid too well you are always on the top of the list to get laid off. In industry today, a PhD equals more money, but can also equal less securtiy if you can get a job at all.
 

FAQ: Gnuplot and adding function name to legend

What is Gnuplot and how does it work?

Gnuplot is a popular open-source command-line program used for creating 2D and 3D plots of data. It works by taking data points and plotting them on a coordinate system, allowing for visualization and analysis of data trends.

How do I add a function name to the legend in Gnuplot?

In Gnuplot, you can add a function name to the legend by using the title command. For example, if you have a function called sin(x), you can add it to the legend by typing plot sin(x) title "Sine Function". This will display the function name in the legend when the plot is generated.

Can I customize the legend in Gnuplot?

Yes, you can customize the legend in Gnuplot by using various commands and options. For example, you can change the position, font, and color of the legend by using the set key command. You can also add a border or background color to the legend using the set key box command.

How do I add multiple functions to the same plot in Gnuplot?

To add multiple functions to the same plot in Gnuplot, you can use the plot command followed by a comma-separated list of functions. For example, plot sin(x), cos(x) will plot both the sine and cosine functions on the same graph. You can also add a function name to each function by using the title command, as mentioned earlier.

Is it possible to use variables in the function name for the legend in Gnuplot?

Yes, you can use variables in the function name for the legend in Gnuplot. This can be helpful if you have multiple plots with similar functions and want to differentiate between them. You can use the set title command to set a variable as the title, and then use that variable in the title command for the legend.

Similar threads

Back
Top