On ubuntu, plot() does not create figure
Show older comments
I just upgraded ubuntu to 20.04 and reinstalled matlab. The plot function does not create a figure window. If I create a figure window with command <figure>, a figure window does appear, but then plot() command does not a draw a plot in it.
3 Comments
Ameer Hamza
on 15 Jun 2020
what if you also input the axes handle to the plot() object. Something like this
fig = figure();
ax = axes(fig);
plot(ax, rand(1,10));
Geoffrey Rogers
on 15 Jun 2020
Wouter Verstraelen
on 24 Feb 2021
See this one: it's an annoying (but known) issue
https://www.mathworks.com/matlabcentral/answers/216942-plotting-and-opengl-error-on-linux-how-to-resolve
Answers (2)
Gayathri
on 19 Dec 2024
I understand that you are facing issues in the "plot" function to generate a "figure" in MATLAB on Ubuntu OS.
Please refer to one of the below mentioned workarounds to resolve the issue.
1. Create a file named "java.opts" in the directory where MATLAB is executed (Eg: /usr/local/MATLAB/R2024b/bin/glnxa64) and include the following line.
-Djogl.disable.openglarbcontext=1
2. Run MATLAB from the terminal using the following command to override the graphics driver.
export MESA_LOADER_DRIVER_OVERRIDE=i965; matlab
3. Launch MATLAB with software OpenGL by using the following command.
matlab -softwareopengl
4. Turn off anti-aliasing for figures by setting the "GraphicsSmoothing" property to "off" .
set(gcf, 'GraphicsSmoothing', 'off');
You can also refer to the following MATLAB Answer to learn more about the workarounds.
For more information, refer to the following MathWorks Documentation to learn about ‘Resolving Low-Level Graphics Issues’.
Hope you find this information helpful.
Ali
on 5 Jan 2025
0 votes
num = [1];
denum = [1 3 1];
g = tf(num, denum);
% Closed-loop system without controller
sys = feedback(g, 1);
figure;
step(sys);
drawnow;
hold on;
title('Step Responses');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
% PID Controller with manual gains
kp = 1;
ki = 1;
kd = 1;
p_manual = pid(kp, ki, kd);
% Closed-loop system with manual PID controller
sys_manual = feedback(p_manual * g, 1);
step(sys_manual);
% PID Tuning
p_tuned = pidtune(g, 'pid');
disp('Tuned PID Gains:');
disp(p_tuned);
% Closed-loop system with tuned PID controller
sys_tuned = feedback(p_tuned * g, 1);
step(sys_tuned);
% Add legend to distinguish responses
legend('Without Controller', 'Manual PID', 'Tuned PID');
Categories
Find more on Tuning Goals in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!