This submission contains the MATLAB code for the technical article "Creating Specialized Charts with MATLAB Object-Oriented Programming". These examples were developed by Ken Deeley and David Sampson at MathWorks. This File Exchange entry contains all code and examples used in the article.
A chart provides a task-specific application programming interface (API) for creating custom visualizations. Designing and implementing a chart not only provides a convenient API for end users, but simultaneously removes the need for the user to manipulate low-level graphics objects.
The code comprises several examples of custom MATLAB charts, together with a chart gallery for browsing the available charts. Enter >> chartGallery at the command line to launch the chart gallery.
You can inspect the source code used for each chart, explore the features and functionality of each chart, and run Live Script examples demonstrating the use of each chart.
Thanks very much for the feedback. Creating a heatmap chart is a great example. You can associate a colormap with an axes as follows.
% Create a figure and an axes.
f1 = figure;
ax = axes(f1);
% Associate a specific colormap to the axes.
% Visualise this by adding a colorbar.
% Next, create a new figure equipped with a different colormap.
f2 = figure('Colormap', summer(64));
% Move the axes to the new figure, then check that the colormaps are preserved.
ax.Parent = f2;
Thank you for this code, it gave me what I needed to get started with some well programmed charts. One comment:
I made a heat-map chart as a way of getting started. I used an Image to present the matrix of numbers and the colormap to set the color representation. However, the colormap is associated with the Figure in Matlab and not an Axes. Consequently, when I change the parent, it take on the colormap of the new figure window. Maybe it would be helpful to make the "parent" property observable, so if it changes I can trigger an "update". It is, however, also possible that I missed something.
Thank you for providing feedback. Further updates to this File Exchange entry are planned. I would be interested to investigate items (1)-(3) with you in more detail. Please email me at <first name> dot <last name> at mathworks dot com with a brief description of the reproduction steps. (4) is fixed for the next release. (5) is a good idea if we release this entry as a toolbox at some point.
A nice ambitious project. It would make me happy to think that this "Chart" object would be continued to be developed.
I have some small issues:
1. The detection of the "GUI Layout Toolbox" does not necessarily work (for me) even though it is installed.
2. The GalleryLauncher misaligns the chart with the image associated with that chart
3. Do you really want to pollute the users name space with your +Data and +Exercise packages (?)
4. Cylinder.mlx contains a saved error
5. Should (or can) this project have the proper MATLAB toolbox parts: help, contents file etc.
Requires GUI Layout Toolbox: https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox
Inspired by: GUI Layout Toolbox