Amazing addtheme functionality!

The Plotly Graphing Library for MATLAB comes pre-loaded with several themes that you can get started using right away, and it also provides support for creating and registering your own themes.

Available Themes

To be more specific, among the different themes that come pre-loaded in matlab_plotly we have:

  • 'ggplot2'
  • 'seaborn'
  • 'simple_white'
  • 'plotly'
  • 'plotly_white'
  • 'plotly_dark'
  • 'presentation'
  • 'xgridoff'
  • 'ygridoff'
  • 'gridon'
  • 'none'

The default theme is 'plotly' but we can use any of the listed themes too! :boom:

Specifying themes in matlab_plotly

To add a specific theme we just have to use the addtheme function that matlab_plotly provides. For this we just have to create the fig2ploty object and pass it as an input argument along with the name of the theme (one of the above). Here is several examples of using addtheme to build and display a histogram chart with different themes.

plotly_dark theme

x = randn(10000,1);
h = histogram(x);
f = fig2plotly(gcf, 'open', false);

addtheme(f, 'plotly_dark');
response = plotlyoffline(f);

web(response, '-browser');

ggplot2 theme

x = randn(10000,1);
h = histogram(x);
f = fig2plotly(gcf, 'open', false);

addtheme(f, 'ggplot2');
response = plotlyoffline(f);

web(response, '-browser');

seaborn theme

x = randn(10000,1);
h = histogram(x);
f = fig2plotly(gcf, 'open', false);

addtheme(f, 'seaborn');
response = plotlyoffline(f);

web(response, '-browser');

plotly_white theme

x = randn(10000,1);
h = histogram(x);
f = fig2plotly(gcf, 'open', false);

addtheme(f, 'plotly_white');
response = plotlyoffline(f);

web(response, '-browser');

1 Like