Combining errorbar() and plot() in same figure?

In summary, I'm having trouble getting started with the MATLAB GUI and found the help page to be helpful.
  • #1
pergradus
138
1
I'm having a little trouble figuring out the MatLab GUI stuff... I'm not used to the way MatLab does things.

At this point all I'd like to do is combine an errobar() and a plot() in the same figure, how would I do this?

Thanks!
 
Physics news on Phys.org
  • #2
If you only have one series of points (x, y, error) then you can use the default errorbar function, as per the examples on the help page below:
http://www.mathworks.com/help/techdoc/ref/errorbar.html

If you have multiple series to plot, you'll probably have to use the hold function (remember to turn it off if you need to replace the plot):
http://www.mathworks.com/help/techdoc/ref/hold.html

As for your other question about getting started in MATLAB GUI, I replied a while ago to another poster facing a similar predicament in a different thread (and some of the advice there may be helpful for you, as well):
https://www.physicsforums.com/showthread.php?t=492673

Don't let it daunt you, and remember that the Mathworks has incredibly complete documentation and tutorials. When MATLABdude is a MATLABdud (which actually happens quite a bit), there's always the Mathworks documentation site (and other posters who didn't actually sign up with a username containing the name of a copyrighted program that they're not affiliated with).
 
  • #3
MATLABdude said:
If you only have one series of points (x, y, error) then you can use the default errorbar function, as per the examples on the help page below:
http://www.mathworks.com/help/techdoc/ref/errorbar.html

If you have multiple series to plot, you'll probably have to use the hold function (remember to turn it off if you need to replace the plot):
http://www.mathworks.com/help/techdoc/ref/hold.html

As for your other question about getting started in MATLAB GUI, I replied a while ago to another poster facing a similar predicament in a different thread (and some of the advice there may be helpful for you, as well):
https://www.physicsforums.com/showthread.php?t=492673

Don't let it daunt you, and remember that the Mathworks has incredibly complete documentation and tutorials. When MATLABdude is a MATLABdud (which actually happens quite a bit), there's always the Mathworks documentation site (and other posters who didn't actually sign up with a username containing the name of a copyrighted program that they're not affiliated with).

Thanks! The hold function did just the trick. I still find the way MATLAB handles graphics weird... I'm used to the way java does things where everything is an object which you must declare.
 

Related to Combining errorbar() and plot() in same figure?

1. Can I plot both error bars and a line graph on the same figure?

Yes, you can use the errorbar() and plot() functions together to create a figure with both error bars and a line graph.

2. How do I customize the error bars and line graph separately?

To customize the error bars, you can use the "fmt" parameter in the errorbar() function. To customize the line graph, you can use the "fmt" parameter in the plot() function.

3. Can I add a legend to the figure?

Yes, you can add a legend to the figure by using the legend() function. You can specify the labels for the legend by using the "label" parameter in the errorbar() and plot() functions.

4. Is it possible to save the figure as an image file?

Yes, you can save the figure as an image file by using the savefig() function. You can specify the file format by using the "format" parameter, such as "png" or "jpg".

5. What happens if my data has multiple sets of error bars?

If your data has multiple sets of error bars, you can use the errorbar() function multiple times with different data and customizations to add all the error bars to the figure.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
315
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top