Multi-colored bar charts: example 6
Pattern-filled bar charts: example 7
Example pages containing: tips | resources | functions/procedures
Multi-colored bar charts: example 6
Pattern-filled bar charts: example 7
bar_1.ncl:
This shows a series of bar charts.The first frame sets gsnXYBarChart to True, which causes each Y value to be represented by a bar pointing upward. The base of each bar is the minimum Y value or the value of trYMinF, if set. Each bar is centered about its corresponding X value.
The second frame additionally sets gsnXYBarChartOutlineOnly to True, which causes each Y value to be represented by a horizontal bar, creating an outline plot. There are no individual bars drawn here. Here, each vertical line is exactly at the corresponding X value, and NOT centered about it like gsnXYBarChart.
The third frame sets gsnYRefLine to 0, causing all the positive Y values to be drawn as bars pointing upward, and all negative Y values to be drawn as bars pointing downward.
bar_2.ncl:
Demonstrates coloring values above and below a reference line with a
particular color.
gsnAboveYRefLineColor = "red", and gsnBelowYRefLineColor = "blue", are the two resources required to shade the bars above and below the reference line.
bar_3.ncl:
Demonstrates changing the size of the bars.
By default, the thickness of each bar is delta-x. You can make the bars smaller than this by setting gsnXYBarChartBarWidth to a smaller number. In this instance, delta-x is 0.66 and we have changed the width to 0.1. Note that at this point it becomes hard to see the bar colors, because the bars are pretty thin.
bar_4.ncl:
Demonstrates turning off bar outline around each bar. This is useful
when you have a lot of data points because the outline is drawn after
the color fill, and a black line and can obscure it.
xyLineColors = (/"red","blue"/), changes the outline color for the above and below color filled areas respectively.
bar_6.ncl:
Demonstrates how to make individual bars different colors within a bar
chart that has a reference line. The colors can be chosen separately
for the above and below bars (first plot), or sequentially regardless
of orientation (second plot).
gsnAboveYRefLineBarColors controls the colors of the bars above the reference line. This is an array. The colors will repeat. gsnBelowYRefLineBarColors controls the colors below the reference line.
gsnXYBarChartColors2 will assign a sequence of colors regardless of bar orientation.
bar_7.ncl:
A bar chart w/o a reference line, and individual colors. The second
frame adds a labelbar.
gsnXYBarChartColors controls the colors of the bars.
bar_8.ncl:
Demonstrates how to make individual bars different colors and
patterns within a bar chart that has a reference line. Colors are
distributed separately for bars above and below the reference line
(first plot), or regardless of orientation of the bars (second plot).
gsnAboveYRefLineBarPatterns controls the patterns of the bars above the reference line. This is an array. The patterns will repeat. gsnBelowYRefLineBarPatterns controls the patterns below the reference line.
gsnXYBarChartPatterns2 will apply the patterns regardless of the orientation of the bars.
There are several patterns to choose from.
bar_9.ncl:
This script creates a single bar chart showing 4 different timeseries
with four different colors. The labelbar is created by using gsn_labelbar_ndc.
polyg_10.ncl:
This example shows how to draw various polylines and polygons on a
several generic tickmark backgrounds to create a series of bar
charts. The gsn_add_polyline and
gsn_add_polygon functions are used
to create the polylines and polygons and gsn_panel is used to panel all the plots on
one frame.
bar_10.ncl:
This script shows how to create a horizontal series of filled bars. A
blank plot was created first
using gsn_blank_plot), and the bars
attached using
using gsn_add_polygon).
bar_11.ncl: This script shows how to
panel multiple bar charts and add a custom legend (using labelbars).
This example is similar to example 9 above, except it uses the overlay procedure to overlay the individual bar plots. Finally, it uses gsn_panel to panel the four sets of plots.
bar_12.ncl: This script shows how to
create four sets of "floating" bars given a set of minimum and maximum values
for each set of bars.
The trick is to draw the plot twice with the same bar color,
first with the minimum values, and then with the maximum values. Each set of
bars has its own gsnYRefLine value.
bar_13.ncl: This script shows
a variation on creating "floating" bars, grouping each set of
bars by a single month.
The data are read in from a dummy data file that contains min, max, and average values for seven different models.
bar_14.ncl: This script shows
how to draw an XY curve on top of a bar chart.
Two separate plots are created, and then they are drawn in the same space by making sure the vpXF, vpYF, vpWidthF, and vpHeightF resources are the same for both.
bar_15.ncl: This script shows
how to draw a bar chart with the bars colored according
to ranges of values. This example includes two frames: one with the
bars flat on top, and one with the top of the bars following the
XY curve.
time_axis_labels is used add nicely-formatted time labels to the X axis.