Combine ListPlot and ErrorListPlot in Mathematica?

  • Mathematica
  • Thread starter wren11
  • Start date
  • Tags
    Mathematica
In summary, the user is trying to combine ListPlot and ErrorListPlot in Mathematica in order to add error bars to a graph while still being able to edit its appearance, legend, and ticks. However, combining the two plots using Show only works if the legend and appearance have not been edited. The solution is to use the "hold on" command before making edits to the graph.
  • #1
wren11
1
0
Combine ListPlot and ErrorListPlot in Mathematica??

Hello,

I'm pretty new to Mathematica and I'm having a problem getting error bars on a plot. I've been using ListPlot to graph points and then edit the appearance of the graph / include legend etc by:
ListPlot["meansdata", Frame -> {{True,False},{True,False}},FrameLabel ->{"Month","Group Size"}, FrameTicks -> {{{1,"Jan"},{2,"Feb"},{3,"Mar"},{4,"Apr"},{5,"May"},{6,"Jun"},{7,"Jul"},{8,"Aug"},{9,"Sep"},{10,"Oct"},{11,"Nov"},{12,"Dec"}},Automatic}, PlotLegend -> {"2009","2010"}] plus LegendPosition / PlotStyle / PlotRange etc.

I would like to add in error bars to this plot but it seems the only way to generate a graph with error bars is to use ErrorListPlot. With this, I seem to lose the option to include a legend and changing the appearance isn't working in the same way. I've tried combining the regular ListPlot and the ErrorListPlot with Show. This only works if I haven't included a legend or changed the appearance.

How can I add error bars to a ListPlot and still edit the appearance, legend, ticks etc? Any help would be greatly appreciated!
 
Physics news on Phys.org
  • #2


try:

hold on

That should "hold" the graph on the screen while you make changes.
 

1. How do I combine ListPlot and ErrorListPlot in Mathematica?

To combine ListPlot and ErrorListPlot in Mathematica, you can use the ErrorListPlot function and specify your data points as a list of {x,y,yerr} tuples. This will plot your data points with error bars. Then, you can use the Show function to combine this plot with your ListPlot data.

2. Can I customize the appearance of the error bars in the combined plot?

Yes, you can customize the appearance of the error bars in the combined plot by using the ErrorBarFunction option in the ErrorListPlot function. This allows you to specify a function to define the style of the error bars, such as thickness, color, or shape.

3. How can I add a legend to the combined plot?

To add a legend to the combined plot, you can use the PlotLegends option in the Show function. You can specify the labels for your ListPlot and ErrorListPlot data separately, and they will be automatically included in the legend.

4. Is it possible to add a trendline to the combined plot?

Yes, you can add a trendline to the combined plot by using the Fit option in the ListPlot function. This will fit a linear or polynomial trendline to your data points and add it to the plot. You can also customize the appearance of the trendline using options such as PlotStyle.

5. Can I export the combined plot as an image or PDF file?

Yes, you can export the combined plot as an image or PDF file by using the Export function in Mathematica. Simply specify the desired file format, and the plot will be saved to your chosen location. You can also customize the resolution and size of the exported image.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
10K
  • Introductory Physics Homework Help
Replies
20
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
Back
Top