BarChart

BarChart[{y1,y2,,yn}]

makes a bar chart with bar lengths y1, y2, .

BarChart[{,wi[yi,],,wj[yj,],}]

makes a bar chart with bar features defined by the symbolic wrappers wk.

BarChart[{data1,data2,}]

makes a bar chart from multiple datasets datai.

Details and Options

Examples

open allclose all

Basic Examples  (4)

Generate a bar chart for a list of heights:

Chart several datasets:

Use categorical labels:

Categorical legends:

Set the style for bars:

Pictorial bars:

Scope  (41)

Data and Layouts  (15)

Items in a dataset are grouped together:

Datasets do not need to have the same number of items:

Nonreal data is taken to be missing and typically yields a gap in the bar chart:

The data may include units:

Specify the units to use:

The time stamps in TimeSeries, EventSeries, and TemporalData are ignored:

The values in associations are taken as the heights of the bars:

Use the keys as labels:

Use the keys as callouts:

Use the keys as legends:

Associations can be nested:

The weights in WeightedData are ignored:

The censoring and truncation information in EventData is ignored:

Use different layouts to display multiple datasets:

Stacked layouts are more compact in the horizontal direction:

Use Joined to indicate connections between data points:

Use a column of charts instead:

Use multiple rows or columns:

Control the origin of bars:

Adjust the spacing between bars and groups of bars:

Plot data with uncertainty:

Wrappers  (5)

Use wrappers on individual data, datasets, or collections of datasets:

Wrappers can be nested:

Override the default tooltips:

Use any object in the tooltip:

Use PopupWindow to provide additional drilldown information:

Button can be used to trigger any action:

Styling and Appearance  (8)

Use an explicit list of styles for the bars:

Use any gradient or indexed color schemes from ColorData:

Use color schemes designed for charting:

ChartBaseStyle can be used to set an initial style for all chart elements:

Style can be used to override styles:

Use any graphic for pictorial bars:

Use built-in programmatically generated bars:

For detailed settings use Palettes ChartElementSchemes:

Use a theme with detailed frame ticks and grid lines:

Use a theme with a high-contrast color scheme and edge-fading rectangles:

Labeling and Legending  (13)

Use Labeled to add a label to a bar:

Use symbolic positions for label placement:

Provide categorical labels for the columns of data:

For rows of data:

For both:

Use Placed to control the positioning of labels, using the same positions as for Labeled:

Use Callout to add a label to a bar:

Change the appearance of the callout:

Automatically position callouts:

Use callouts with stacked bars:

Provide value labels for bars by using LabelingFunction:

Use Placed to control placement and formatting:

Use Callout to create callouts:

Add categorical legend entries for the columns of data:

For rows of data:

Use Legended to add additional legend entries:

Use Placed to affect the positioning of legends:

Options  (133)

AspectRatio  (3)

By default, BarChart uses a fixed ratio of height to width for the chart:

The ratio is not affected when the bars are horizontal:

Make the height the same as the width with AspectRatio1:

AspectRatioFull adjusts the height and width to tightly fit inside other constructs:

Axes  (3)

By default, axes are drawn:

Use AxesFalse to turn off axes:

Use AxesOrigin to specify where the axes intersect:

AxesLabel  (4)

No axes labels are drawn by default:

Place a label on the axis:

Specify axes labels:

Use units as labels:

AxesOrigin  (2)

The position of the axes is determined automatically:

Specify an explicit origin for the axes:

AxesStyle  (4)

Change the style for the axes:

Specify the style of each axis:

Use different styles for the ticks and the axes:

Use different styles for the labels and the axes:

BarOrigin  (1)

Change the bar origin:

BarSpacing  (5)

Use automatically determined spacing between bars:

Use no spacing:

Use symbolic presets:

Use explicit spacing between bars:

Use explicit spacing between bars and groups of bars:

ChartBaseStyle  (5)

Use ChartBaseStyle to style bars:

ChartBaseStyle combines with ChartStyle:

ChartStyle may override settings for ChartBaseStyle:

ChartBaseStyle combines with Style:

Style may override settings for ChartBaseStyle:

ChartBaseStyle combines with ColorFunction:

ColorFunction may override settings for ChartBaseStyle:

ChartElementFunction  (6)

Get a list of built-in settings for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

This ChartElementFunction is appropriate to show the global scale:

Write a custom ChartElementFunction:

Use metadata passed on from the input, in this case charting the data:

Built-in element functions may have options; use Palettes ChartElementSchemes to set them:

ChartElements  (9)

Create a pictorial chart based on any Graphics object:

Graphics3D:

Image:

Use a stretched version of the graphic:

Use explicit sizes for width and height:

Without AspectRatio->Full, the original aspect ratio is preserved:

Using All for width or height causes that direction to stretch to the full size of the bar:

Use a different graphic for each column of data:

Use a different graphic for each row of data:

Graphics are used cyclically:

Styles are inherited from styles set through ChartStyle etc.:

Explicit styles set in the graphic will override other style settings:

The orientation of the pictorial graphic is unaffected by BarOrigin:

Create true 3D shaded bars:

ChartLabels  (10)

By default, labels are placed in the axis:

Labeled wrappers in data will place additional labels:

Use Placed to control label placement:

Symbolic positions outside the bar:

Coordinate-based placement relative to a bar:

Place all labels at the upper-right corner and vary the coordinates within the label:

Use the third argument to Placed to control formatting:

Use a hyperlink label:

Rotate the labels:

By default, labels are associated with columns of data:

Associate labels with rows or datasets:

Label both rows and columns:

Use Placed to affect placements:

Use Callout to connect the labels to the bars:

Place multiple labels:

ChartLayout  (5)

ChartLayout is grouped by default:

Use stepped bars:

Use stacked bars:

The stacked layout can effectively display many datasets:

Show changes for different categories by setting Joined->True:

Place individual charts in a column:

Use a row instead of a column:

Use multiple columns or rows:

Prefer full columns or rows:

ChartLegends  (8)

Generate a legend based on chart style:

Use Legended to add additional legend entries:

Use Legended to specify individual legend entries:

Legended adds additional legend entries:

Generate a legend for datasets:

Unused legend labels are dropped:

Legends can be applied to several dimensions:

Use Placed to control the placement of legends:

ChartStyle  (8)

Use ChartStyle to style bars:

Give a list of styles:

Use the "Gradients" color scheme from ColorData:

Use the "Indexed" color scheme from ColorData:

Use indexed colors optimized for charting:

Styles are used cyclically:

Style each column of data:

Style each row of data:

Style both rows and columns of data:

With both row and column styles, the last style may override earlier ones:

Style overrides settings for ChartStyle:

ColorFunction overrides settings for ChartStyle:

ChartElements may override settings for ChartStyle:

ColorFunction  (3)

Color by bar height:

Use ColorFunctionScaling->False to get unscaled height values:

ColorFunction overrides styles in ChartStyle:

Use ColorFunction to combine different style effects:

ColorFunctionScaling  (2)

By default, scaled height values are used:

Use ColorFunctionScaling->False to get unscaled height values:

Frame  (4)

BarChart does not use a frame by default:

Use FrameTrue to turn on the frame:

Draw a frame on the left and right edges:

Draw a frame on the left and top edges:

FrameLabel  (3)

Place a label along the bottom of a chart:

Frame labels are placed on the bottom and left frame edges by default:

Place labels on each of the edges in the frame:

FrameStyle  (2)

Specify the style of the frame:

Specify style for each frame edge:

FrameTicks  (8)

Frame ticks are placed automatically by default:

Use All to include tick labels on all edges:

Place tick marks at specified positions:

Draw frame tick marks at the specified positions with specific labels:

Specify the lengths for tick marks as a fraction of the graphics size:

Use different sizes in the positive and negative directions for each tick mark:

Specify a style for each frame tick:

Construct a function that places frame ticks at the midpoint and extremes of the frame edge:

FrameTicksStyle  (3)

By default, the frame ticks and frame tick labels use the same styles as the frame:

Specify an overall style for the ticks, including the labels:

Use different style for each frame edge:

ImageSize  (7)

Use named sizes such as Tiny, Small, Medium and Large:

Specify the width of the plot:

Specify the height of the plot:

Allow the width and height to be up to a certain size:

Specify the width and height for a graphic, padding with space if necessary:

Setting AspectRatioFull will fill the available space:

Use maximum sizes for the width and height:

Use ImageSizeFull to fill the available space in an object:

Specify the image size as a fraction of the available space:

IntervalMarkers  (2)

By default, uncertainties are capped:

Use "Bars" to denote uncertainties without caps:

IntervalMarkersStyle  (2)

Interval markers contrast with the bars by default:

Use multiple datasets:

Specify the style for uncertainties:

Joined  (3)

By default, bars are not joined:

Join the centers of the tops of the bars:

Join the corners of the bars:

Join stacked bars:

LabelingFunction  (8)

Use automatic labeling by values through Tooltip and StatusArea:

Do no labeling:

Use symbolic positions to control label placement:

Symbolic positions outside the bar:

Coordinate-based placement relative to a bar:

Use Callout to place labels automatically:

Use symbolic positions to place Callout labels:

Control the formatting of labels:

Use the given chart labels as arguments to the labeling function:

Place complete labels as tooltips:

LabelingSize  (4)

Textual labels are shown at their actual sizes:

Image labels are automatically resized:

Specify a maximum size for textual labels:

Specify a maximum size for image labels:

Show image labels at their natural sizes:

PerformanceGoal  (3)

Generate a bar chart with interactive highlighting:

Emphasize performance by disabling interactive behaviors:

Typically, less memory is required for non-interactive charts:

PlotTheme  (2)

Use a theme with simple ticks and grid lines in a high-contrast color scheme:

Change the color scheme:

ScalingFunctions  (4)

By default, plots have linear scales in each direction:

Use a log scale in the direction:

Use a scale defined by a function and its inverse:

Positions in Ticks and GridLines are automatically scaled:

Applications  (11)

Create a bar chart of the frequency of characters in the Declaration of Independence:

Apply labels at multiple levels:

Click the color selector and see the bar chart of updated color components:

Click the bars to hear the name of the country and its GDP per capita:

Create a progressive bar chart:

Create a progressive column graph:

Create a Gantt chart of employees' holidays in January:

Mouse over the bars and grid lines for the number of days:

Use images of textures from ExampleData as pictorial bars:

Color the textures:

Create a bar chart with textured bars:

Acoustically compare the percentage price change of a list of companies:

Click a dataset in the bar chart to hear an acoustic representation of the values:

Compare price trends for a portfolio of companies:

Create a labeling function:

Mouse over the bars to get price information:

Compare common length measures in centimeters:

Properties & Relations  (6)

Use BarChart3D to get a 3D rendering of bar charts:

BarChart is a special case of RectangleChart:

Use PieChart and PieChart3D to visualize a list of data as sectors:

Use ListPlot and ListLinePlot to produce line graphs:

Use Histogram to automatically compute binning and draw histograms:

Use PairedBarChart to create bilateral bar charts:

Neat Examples  (3)

Chartwork with stacked bars:

Chartwork with stacked bars:

Chartwork with percentile bars:

Wolfram Research (2008), BarChart, Wolfram Language function, https://reference.wolfram.com/language/ref/BarChart.html (updated 2021).

Text

Wolfram Research (2008), BarChart, Wolfram Language function, https://reference.wolfram.com/language/ref/BarChart.html (updated 2021).

CMS

Wolfram Language. 2008. "BarChart." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/BarChart.html.

APA

Wolfram Language. (2008). BarChart. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BarChart.html

BibTeX

@misc{reference.wolfram_2024_barchart, author="Wolfram Research", title="{BarChart}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/BarChart.html}", note=[Accessed: 06-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_barchart, organization={Wolfram Research}, title={BarChart}, year={2021}, url={https://reference.wolfram.com/language/ref/BarChart.html}, note=[Accessed: 06-November-2024 ]}