Hot answers tagged

8

There are two problems. One is that in your DSolve call, you should solve for the functions {a, b, ...} instead of the expressions {a[t], b[t],...}. (In my experience, it's almost always better this way.) The other is that to get the proper list structure for BarChart, you should use First@DSolve[..] to remove an unnecessary `{}. dsol = First@ ...


7

Perhaps this: Get the tick values: ticks = FrameTicks /. Options[First @ bars, FrameTicks] Get the x tick values: xticks = ticks[[2, 1, All, 1]] Visualize the x tick values with dots on top of the bar chart: Show[bars, Graphics[{AbsolutePointSize[4], Point[{#, 0}]} & /@ xticks]] This gives you all the center points of each bar, but also ...


7

Here is a version that builds up the "full Tufte" version of the plot presented above by building up the corresponding Graphics primitives. Quite a few styling decisions must be made with respect to colors, spacings, overall aspect ratio of the plot, etc. I went with choices that were aesthetically pleasing to me, but of course it should be relatively easy ...


6

I'm not sure whether this is documented or not. You can pass additional arguments to the ChartElementFunction like this: r[{{xmin_, xmax_}, {ymin_, ymax_}}, y_, {origin_}] := Rectangle[{xmin, ymin + origin}, {xmax, ymax + origin}] BarChart[{{1} -> 1, {1} -> 2, {2} -> 3}, ChartElementFunction -> r] edit Perhaps ...


6

Why not simply data = Table[RandomInteger[{1, 20}], {20}]; Define the partition par = {{1, 8}, {9, 13}, {14, 16}, {17, 20}}; Plot BarChart[ Take[data, #] & /@ par, ChartLabels -> {{"1st", "2d", "3rd", "4th"}, CharacterRange["a", "t"]}] Update bar = BarChart[ data, ChartLabels -> CharacterRange["a", "t"]]; lip = ListPlot[ ...


6

You can divide all of your data by 1/10th of the smallest absolute value before doing the log transform. This essentially scales the data to all have logs greater than one without adding a discontinuity on your axis. Then you can show the sign*log of positive and negative values from your original data on the same axis. d = {-3.7*^-7, -1.81*^8, 1.5*^6, ...


6

Module[{data, range}, data = TimeSeries[#, ResamplingMethod -> {"Constant", 0}] &@{{1891, 1}, {1892, 1}, {1897, 1}, {1898, 1}, {1903, 1}, {1904, 1}, {1905, 1}, {1908, 4}, {1909, 6}, {1910, 6}, {1911, 16}, {1912, 33}, {1913, 35}, {1914, 43}, {1915, 39}, {1916, 31}, {1917, 42}, {1918, 52}, {1919, 44}, {1920, 53}, {1921, 33}, ...


6

Depending on exactly what you're trying to do, adding Frame->{False,True,False,False},Axes->{True,False},PlotRangePadding->None to keep your x axis and use only the frame on the y-axis should work. BarChart[{{0.123, 0.492}, {2.865, 0.055}, {1.03, 1.084}, {4.282, 0.053}} , AxesLabel -> {None, Rotate["Value", 90 Degree]} , ChartLabels -> ...


5

This isn't pretty, but it works: BarChart[{ {Labeled[1,"c1"],Labeled[3,"c2"],Labeled[4,"c3"]},{Labeled[4,"c4"], Labeled[5,"c5"]}}, ChartLabels -> {{"r1","r2"},None} ]


5

A small change to the LabelingFunction seems to do the trick: BarChart[{{0.123, 0.492}, {2.865, 0.055}, {1.03, 1.084}, {4.282, 0.053}}, AxesLabel -> {"", "Value"}, ChartLabels -> {Placed[{"data1", "data2", "data3", "data4"}, {{0.5, 0}, {0.8, 1.2}}, Rotate[#, (1.75/7) Pi] &], Placed[{"", ""}, Above]}, LabelingFunction -> ( ...


5

I assume it is asked to find the tallies for (1) "source", (2) "target", and (3) the sequence of words "source", "and", "target". If that is the case this code does it. words = {"source", "source", "and", "target", "source", "and", "target", "target", "source", "and", "target", "target", "source", "and", "target", "target", "target", "target", ...


5

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.


5

bar = BarChart[{{4, 4, 1, 0.05}, {3, 3, 1, 1}, {1, 1, 2, 2}, {2, 2, 4, 4}}] c = Cases[bar[[1]], _RGBColor, Infinity] Union@c // InputForm {RGBColor[0.4992, 0.5552, 0.8309304], RGBColor[0.7116405333333333, 0.4816, 0.5483194666666666], RGBColor[0.928, 0.5210666666666667, 0.2], RGBColor[0.982864, 0.7431472, 0.3262672]}


4

Maybe here's a small improvement Show[ bars, ListLinePlot[means, DataRange -> {2.6, 19}], ListPlot[means, DataRange -> {2.6, 19}], GridLines -> {{2.6, 6.7, 10.8, 14.9, 19}, {1, 2, 3, 4}}, ImageSize -> Large, ImagePadding -> {{10, 10}, {10, 10}}] The gridlines run through the centers of the "meshpoints" and are uniformely spaced at ...


4

You can use the metadata form of BarChart's data elements, $\text{form}_i\to m_i$, to specify the bar colour when a category is omitted. You do have to specify the colours in ChartStyle as well. data = {{1,2,3},{None,2,None},{1,None,5}}; BarChart[ First@MapThread[ Thread@*Rule, { {data /. None -> Nothing}, {Pick[{Orange, Brown, Blue}, #, ...


4

Is it sufficient to simply visualise the RealExponent - in this case, at least. I added some chart junk for added benefit. BarChart[RealExponent[{mylist1[[All, 2]], mylist2[[All, 2]]}]/.-Infinity->0, AxesOrigin -> {0, 0}, AxesLabel -> {"", "Exponent"}, ChartLegends -> mylist1[[All, 1]], ChartLabels -> {Placed[{Panel["mylist1"], ...


4

You can define a function to label the data using Labeled as in @David's answer: lblngF = MapIndexed[Function[{d, p},Labeled[d, #2[[1]][[## & @@ p]]]], #, {#2[[2]]}] &; lblF = Fold[lblngF, #, Thread[{Reverse@#2, {2, 1}}]] &; dt = {{1, 3, 4}, {4, 5}}; labels = {{"r1", "r2"}, {{"c1", "c2", "c3"}, {"c4", "c5"}}}; BarChart[lblF[dt, labels]] ...


4

While not a Bar Chart per se, I usually prefer to use the result from HistrogramList directly with ListPlot and then join the points with InterpolationOrder->0. SeedRandom[1465]; data = RandomVariate[NormalDistribution[0, 1], 1000]; mapoints=Thread[{#[[1]], Append[#[[2]], 0.0]}] &@HistogramList[data]; ListPlot[mapoints, Joined -> True, ...


3

You can use RectangleChart with the option setting BarSpacing->-1: opts1 = {BarSpacing -> -1, ChartStyle -> {Opacity[.5, Red], Opacity[.5, Green]}}; rc1 = RectangleChart[{{2, 1}, {3, 4}}, opts1] To add the ticks to the horizontal axis: opts2 = Join[opts1, {Frame -> {True, True, False, False}, FrameTicks -> {{#, # + 1} & /@ ...


2

The function errorBar can be found in the Documentation Center page How to -- Add Error Bars to Charts and Plots. You can change the function errorBar to take a scaling function argument: errorBar2[sf_: Identity, type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, meta_] := Block[{error, isf = InverseFunction[sf][y1]}, error = Flatten[meta]; ...


2

In version 10+ there is NumberLinePlot that can be used for this. NumberLinePlot[Interval[Rest@#] & /@ Reverse[giniCoefficients, 1], PlotStyle -> (Directive[#, Thin, PointSize[Large]] & /@ {Orange, Blue}), PlotRange -> {{2, Automatic}, Automatic}, PlotRangePadding -> Scaled[.05], Epilog -> MapIndexed[ Function[{item, ...


2

It's quite easy once one finds out the correct symbols for the various indices. I found them on Yahoo. Column[ TradingChart[{#, {{2015, 7, 24}, {2015, 8, 24}}}, {"Volume", "SimpleMovingAverage", "BollingerBands"}, PlotLabel -> #, ImageSize -> Medium] & /@ {"SP500", "^AXJO", "^SSEC", "^N225"}, Spacings -> ...


2

You can explicitly specify this in the plot: ErrorListPlot[{{{1, 1}, ErrorBar[0.2]}, {{2, 2}, ErrorBar[None]}, {{3, 4}, ErrorBar[0.3]}, {{4, 6}, ErrorBar[None]}, {{5, 7}, ErrorBar[0.8]}, {{6, 10}, ErrorBar[None]}}] Per your comment, perhaps this fits the need: Needs["ErrorBarPlots`"] (* fake some data *) data = ...


2

Another way, using Frame (you need to shift your endpoints by 0.5 to match the bars) data = Transpose@{CharacterRange["a", "t"], Table[RandomInteger[{1, 20}], {20}]}; plot1 = BarChart[data[[All, 2]], ChartLabels -> data[[All, 1]]]; plot2 = Plot["", {x, 1, 20}, Frame -> {{False, False}, {True, False}}, Axes -> False, FrameTicks -> ...


2

For a quick and dirty method you could make use of RectangleChart as your second where the width of each rectangle is equal to the number of items in the top groups. Grouping your data in the BarChart will assist with visualising this. bc = BarChart[Partition[data[[All, 2]], 5], ChartLabels -> {IntegerName[Range[4]], CharacterRange["a", "t"]}]; rc = ...


2

I think you want to use RectangleChart for this purpose. First you need to make a new data set which contains the widths of each bar. Here's the data manipulation: data = {{1,2,3},{None,2,None},{1,None,5}}; data2 = data /. None->0 data3 = Table[{HeavisideTheta[data2[[i, j]] - 0.1], data2[[i, j]]}, {i, 1, 3}, {j, 1, 3}]; The HeavisideTheta function ...


1

This worked for me at the end: errorBar3D[b : {{x0_, x1_}, {y0_, y1_}, {z0_, z1_}}, value_, meta_] := Block[{error}, error = Flatten[meta]; error = If[error === {}, 0, Last[error]]; {ChartElementDataFunction["Cylinder", "Profile" -> 2][b], {Black, Opacity[0.7], Line[{{{(x0 + x1)/2, (y0 + y1)/2, z1 - error}, {(x0 + x1)/2, (y0 ...


1

Maybe BoxWhiskerChart with omitted Median- and QuantileMarkers: data = {{1, 2, 3, 1, 4, 0}, {-1, 2, 3, 3, 4, 5}, {3, 3, 4, 5, 2, 9}}; mean = Round[#, 0.1]& @ (Mean /@ data) {1.8, 2.7, 4.3} BoxWhiskerChart[ data, {"Mean", {"MedianMarker", Opacity@0.0}}, ChartLabels -> Placed[mean, Center], ChartStyle -> White] On the other hand, you ...


1

BarChart[#2, ChartLabels -> #1] & @@ Transpose[Tally[data]]


1

On my computer Windows 7, Mathematica 9, your code renders a perfectly black bar! To understand if problem may be OS or Mathematica version related, please specify OS and Mathematica version.



Only top voted, non community-wiki answers of a minimum length are eligible