Mathematica Barchart Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about mathematica horizontal error bars Stack Overflow the company Business Learn more about hiring developers or posting ads with
Asymmetric Error Bars Mathematica
us Mathematica Questions Tags Users Badges Unanswered Ask Question _ Mathematica Stack Exchange is a question and answer site for users mathematica error bar style of Mathematica. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top barchart mathematica ErrorBars with BarChart, ChartLabels are not working? up vote 6 down vote favorite In the Add Error Bars to Charts and Plots How To in the Mathematica documentation a function ErrorBar is given: errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, meta_] := Block[{error}, error = Flatten[meta]; error = If[error === {}, 0, Last[error]]; {ChartElementData[type][{{x0, x1}, {y0, y1}}, value, meta], {Black, Line[{ {{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2, y1
Mathematica Errorlistplot Not Working
+ error}}, {{1/4 (3 x0 + x1), y1 + error}, {1/4 (x0 + 3 x1), y1 + error}}, {{1/4 (3 x0 + x1), y1 - error}, {1/4 (x0 + 3 x1), y1 - error}} }] }} ] that adds error bars to BarChart. Here is an example using some random data with random errors: chartData = MapThread[{#1 -> #2} &, {RandomReal[1, 10], RandomReal[0.1, 10]}] and some random labels: labels = ToString /@ RandomReal[100000, 10] Now plotting it, as per the tutorial: BarChart[chartData, ChartElementFunction -> errorBar["Rectangle"], ChartLabels -> Placed[labels, Axis, Rotate[#, Pi/2] &]] The labels are: {"99539.6", "17862.9", "14683.4", "32667.2", "42690.", "70230.8", "59050.4", "59204.7", "9138.2", "19080.3"} However, in the plot: The first label is repeated incorrectly for all the bars, what's going on here? Without error bars the labels on the plot are correct: BarChart[RandomReal[1, 10], ChartLabels -> Placed[labels, Axis, Rotate[#, Pi/2] &]] graphics plotting share|improve this question edited Mar 17 at 15:38 István Zachar 28.8k1493220 asked Mar 6 '12 at 22:10 s0rce 6,06622465 add a comment| 1 Answer 1 active oldest votes up vote 7 down vote accepted In the original code, chartData is of the form {{value1 -> error1}, {value2 -> error2}, ... }, but it should be of the form {value1 -> error1, v
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers errorbar plotting package mathematica download or posting ads with us Mathematica Questions Tags Users Badges Unanswered Ask Question _ Mathematica Stack mathematica error bar package Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute: Sign up Here's how it works:
Mathematica Stacked Bar Chart
Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top BarChart with error bars up vote 0 down vote favorite 1 I need to plot BarChart with the error bars. http://mathematica.stackexchange.com/questions/2654/errorbars-with-barchart-chartlabels-are-not-working What's the most straightforward way to do it?#plot range from 8 to 10 {8.5,8.6,8.9,9.5} and error bars of 0.1 and labeling of a,b,c and d. Is there something like "ErrorBarPlots`" package which I can use for BarChart? plotting error share|improve this question edited Apr 19 at 16:15 asked Apr 19 at 15:19 faf 366 Have you seen this? –BlacKow Apr 19 at 15:22 @BlacKow yes, But for my simple case, there should be a simple http://mathematica.stackexchange.com/questions/113016/barchart-with-error-bars way. –faf Apr 19 at 15:23 Your x intervals aren't equal. What about your bars? you want them to have the same width or different width? ListLinePlot with Filling option? –BlacKow Apr 19 at 16:22 @BlacKow x intervals are the same and just labels. –faf Apr 19 at 16:42 ` {8.5,8.6,8.9,9.5}` definitely not the same. Do you need these number represented on your plot? Or it will be just four bars labeled a,b,c,d? –BlacKow Apr 19 at 16:45 | show 1 more comment 2 Answers 2 active oldest votes up vote 2 down vote accepted I'm not sure how is it simple, but something like this should work. As a bonus you can change bar width. Needs["ErrorBarPlots`"] prepData[data_, size_] := {{#2 - size/2, 0}, {#2 - size/2, #1}, {#2 + size/2, #1}, {#2 + size/2, 0}} & @@@ MapIndexed[{#1, First@#2} &, data] // Flatten[#, 1] & data = {{8.5, 8.6, 8.9, 9.5}, {"a", "b", "c", "d"}}; Show[ListLinePlot[prepData[#1, 0.9], Filling -> Axis, PlotRange -> {Automatic, {8, 10}}, Ticks -> {MapIndexed[{First@#2, #1} &, #2], Automatic}], ErrorListPlot@ MapIndexed[{{First@#2, #1}, ErrorBar[0.1]} &, #1]] & @@ data share|improve this answer edited Apr 19 at 18:03 answered Apr 19 at 17:21 BlacKow 4,036421 Well done, thanks. –faf Apr 19 at 17:27 add a comment| up vote 2 down vote data = {{8.5, 8.6, 8.9, 9.5}, {"a", "b", "c", "d"}}; bcdata = # -> RandomReal
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://mathematica.stackexchange.com/questions/35462/how-to-plot-barchart-with-error-bars-on-logarithmic-scale-in-mathematica-9 policies of this site About Us Learn more about Stack Overflow the http://mathematica.stackexchange.com/questions/95020/barchart-edgeform-not-producing-correct-colors company Business Learn more about hiring developers or posting ads with us Mathematica Questions Tags Users Badges Unanswered Ask Question _ Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute: Sign up Here's how it works: Anybody error bar can ask a question Anybody can answer The best answers are voted up and rise to the top How to plot BarChart with error bars on logarithmic scale in Mathematica 9? up vote 8 down vote favorite 1 I'm quite new in Mathematica, and I would like to ask you to consider the next case: I need to plot bar mathematica error bar chart with error bars on logarithmic scale. From Wolfram site I took the function which allows to plot error bars on a bar chart with normal (non-log) scaling. Thus, my ugly actual code looks like: errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, meta_] := Block[{error}, error = Flatten[meta]; error = If[error === {}, 0, Last[error]]; { ChartElementData[type][{{x0, x1}, {y0, y1}}, value, meta], {Black, Line[{{{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2, y1 + error}}, {{1/4 (3 x0 + x1), y1 + error}, {1/4 (x0 + 3 x1), y1 + error}}, {{1/4 (3 x0 + x1), y1 - error}, {1/4 (x0 + 3 x1), y1 - error}}}]} } ] figdata = {{4.01 -> 0.76, 1.73 -> 0.14, 3.95 -> 0.35}, {68.53 -> 16.32, 77.77 -> 11.13, 81.39 -> 27.32}}; xlables = {"r1", "r2"}; leftframename = "Frequency"; BarChart[ figdata, ChartElementFunction -> errorBar["Rectangle"], ChartStyle -> {White, Gray, Black}, ChartLabels -> {xlables, None}, FrameLabel -> {None, Style[leftframename, 15, FontFamily -> "OpenSans"]}, FrameTicks -> {{{0, 10, 100, 1000}, None}, {None, None}}, Frame -> Left, BarSpacing -> {0, 0.5}, BaseStyle -> {FontWeight -> "Bold", FontSize
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Mathematica Questions Tags Users Badges Unanswered Ask Question _ Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top BarChart EdgeForm not producing correct colors up vote 2 down vote favorite EdgeForm is not producing correct colors for the borders of my bars. My code: data1 = {{1, 20, 300}, {.1, .2, .2}}; errorbarwidth = -0.1; thickness = 0.005; barchart[x_, thick_] := Module[{}, errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, meta_] := Block[{error}, error = Flatten[meta]; error = If[error === {}, 0, Last[error]]; {ChartElementData[type][{{x0, x1}, {y0, y1}}, value, meta], {Black, Line[{{{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2, y1 + error}}, {{1/4 (3 x0 + x1) - x, y1 + error}, {1/4 (x0 + 3 x1) + x, y1 + error}}, {{1/4 (3 x0 + x1) - x, y1 - error}, {1/4 (x0 + 3 x1) + x, y1 - error}}}]}}]; chartData = MapThread[#1 -> #2 &, data1]; BarChart[chartData, ChartElementFunction -> errorBar["Rectangle"], AspectRatio -> 0.6, ScalingFunctions -> "Log", AxesStyle -> {Thickness[thick], Thickness[thick]}, ChartStyle -> {Directive[White, EdgeForm[{Thickness[thick], Black}]], Directive[Gray, EdgeForm[{Thickness[thick], Black}]], Directive[Black,EdgeForm[{Thickness[thick], Black}]]}, ChartLabels -> {Text[Style[label1, 14]], Text[Style[label2, 14]], Text[Style[label3, 14]]}, ImageSize -> 700]] plot1 = barchart[errorbarwidth, thickness] My EdgeForm commands are all specifying the edges to be black, but they come out gray. I am using Mathematica 9 BTW. plotting graphics style charts share|improve this question asked Sep 19 '15 at 16:34 ahle6481 14110 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote I figured it out -- turns out the default opacity is not 1 for the borders, making them appear gray. I modified EdgeForm: EdgeForm[{Thickness[thick], Black, Opacity[1]}] and it worked just fine. share|improve this answer answered Sep 19 '15 at 16:46 ahle6481 14110 2 Thanks for sharing your solution. –Mr.Wizard♦ Sep 19 '15 at 19:04 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest