MATLAB bar3 in MATLAB®
Learn how to make 4 bar3 charts in MATLAB, then publish them to the Web with Plotly.
Create 3-D Bar Graph
Load the data set count.dat
, which returns a three-column matrix, count
. Store Z
as the first 10 rows of count
.
load count.dat Z = count(1:10,:);
Create a 3-D bar graph of Z
. By default, the style is detached
.
figure
bar3(Z)
title('Detached Style')
fig2plotly('TreatAs', 'bar3')
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_0_0_create_3_d_bar_graph_ssim_map.png)
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_0_0_create_3_d_bar_graph_montage.png)
Specify Bar Width for 3-D Bar Graph
Load the data set count.dat
, which returns a three-column matrix, count
. Store Z
as the first 10 rows of count
.
load count.dat Z = count(1:10,:);
Create a 3-D bar graph of Z
and set the bar width to 0.5.
width = 0.5; figure bar3(Z,width) title('Bar Width of 0.5') fig2plotly('TreatAs', 'bar3')
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_1_0_specify_bar_width_for_3_d_bar_graph_ssim_map.png)
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_1_0_specify_bar_width_for_3_d_bar_graph_montage.png)
3-D Bar Graph with Grouped Style
Load the data set count.dat
, which returns a three-column matrix, count
. Store Z
as the first 10 rows of count
.
load count.dat Z = count(1:10,:);
Create a 3-D bar graph of Z
. Group the elements in each row of Z
by specifying the style option as grouped
.
figure bar3(Z,'grouped') title('Grouped Style') fig2plotly('TreatAs', 'bar3')
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_2_0_3_d_bar_graph_with_grouped_style_ssim_map.png)
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_2_0_3_d_bar_graph_with_grouped_style_montage.png)
3-D Bar Graph with Stacked Style
Load the data set count.dat
, which returns a three-column matrix, count
. Store Z
as the first 10 rows of count
.
load count.dat Z = count(1:10,:);
Create a 3-D bar graph of Z
. Stack the elements in each row of Z
by specifying the style option as stacked
.
figure bar3(Z,'stacked') title('Stacked Style') fig2plotly('TreatAs', 'bar3')
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_3_0_3_d_bar_graph_with_stacked_style_ssim_map.png)
![](https://raw.githubusercontent.com/plotly/ssim_baselines/main/out_matlab/matlab/code-examples/discrete-data-plots/bar3/plot_3_0_3_d_bar_graph_with_stacked_style_montage.png)