MATLAB Diagrams Library
May 28, 2025 ยท View on GitHub
Create paper-quality vector graphics geometry diagrams in 2D and 3D
Capabilities
- Angle Arc (and Arc)
- Arrow
- Circle
- Cone
- Cylinder
- Cylinder Line (for connecting two cylinders)
- Dot
- Line
- Perpendicular Mark
- Plane
- Robot Diagram (compatible with general-robotics-toolbox)
- Sphere
- Text
Papers using this library
Open an issue to add your paper to this list!
IK-Geo: Unified robot inverse kinematics using subproblem decomposition
Alexander J. Elias and John T. Wen
Mechanism and Machine Theory 209, 105971, 2025
Redundancy parameterization and inverse kinematics of 7-DOF revolute manipulators
Alexander J. Elias and John T. Wen
Mechanism and Machine Theory 204, 105824, 2024
Path Planning and Optimization for Cuspidal 6R Manipulators
Alexander J. Elias and John T. Wen
arXiv preprint arXiv:2501.18505, 2025
Examples
Instructions
Download the library code and make sure the +diagrams folder is inside a folder in the MATLAB path.
Example code is shown in usage.m, as well as in the examples folder.
Set up a new figure by running h_fig = diagrams.setup(). Then, add graphics objects to the figure by calling the diagrams library, or by using matlab functions like plot and plot3.
Certain graphics objects must be redrawn depending on the camera angle. At the end of your script, you should call diagrams.redraw(). You can also press any keyboard key to call diagrams.redraw() if you're moving the camera position interactively.
To export the figure, call diagrams.save(h_fig, name, location). This will save the figure in both .eps and .svg format.
The figure is designed to be displayed 3.5 in wide to fit the width of an IEEE journal article. However, there is a 2x scaling factor so that the MATLAB figure window is a reasonable size on a computer screen. To include the figure in LaTeX, you should use \includegraphics[scale=0.5, clip]{diagram.eps}. Adding clip makes sure any white space doesn't overlap with text.
If you're submitting to arXiv and want to use pdfLaTeX, you will need to convert the eps files to pdf files. arXiv doesn't do this conversion.
If you have miktex installed, run the command
epstopdf --outfile=diagram-converted-to.pdf diagram.eps
Or, run the following .bat file on Windows:
for %%I in (*.eps) do (
epstopdf --outfile="%%~nI-converted-to.pdf" "%%I"
)
IF you're using Overleaf, you can download the converted files from the Other logs and files download option.
Then, you can include the PDF file using \includegraphics[scale=0.5, clip]{diagram-converted-to.pdf}
Creating GIFs
Method 1: exportgraphics()
To make sure the gif stays the same size, make a rectangle that fills the whole frame.
annotation('rectangle',[0 0 1 1]);
You may want to use campos(), camva(), and camtarget() to lock the camera view.
At the end of the animation loop, use exportgraphics to save each frame to a file.
exportgraphics(gca, "filename.gif", "Append", i ~= 1)
Method 2: imwrite()
This method gives more control over delay time and other options.
filename = "file_name.gif";
clear im
for i = 1:N
% Code here
frame = getframe(h_fig);
im{i} = frame2im(frame);
end
for idx = 1:length(im)
[A, map] = rgb2ind(im{idx}, 256);
if idx == 1
imwrite(A, map, filename, "gif", "LoopCount", Inf, "DelayTime", 0.5);
else
imwrite(A, map, filename, "gif", "WriteMode", "append", "DelayTime", 0.5);
end
end
Contributing
If you have any improvements you'd like to make, or even ideas or requests for improvements, please start a GitHub issue.