How can I improve my plots including a dashed line

2 views (last 30 days)
Hello, I am developing a code where I need to create a plot that incorporates fitted values on a semi-logarithmic scale on the x-axis, but I also need to insert a dashed line in the center of the plot (when y = 0). I am attaching an example of how I am doing it, but the line is not being displayed in the figure.
figure
semilogx(data_resi_inter.PGA1100,delta_ij_inter,'^r');
hold on
plot([0 0.6],[0 0],'k--','LineWidth',1.0) % dashed line
title('Delta term vs PGA1100');
subtitle('for Interface EQs & T = PGA');
ylabel('Delta_{ij}');
xlabel('PGA1100 [g]');
grid on
On the other hand, I would like to know if there is a way to make all the figures (which in my case are 6 of the same type) appear on the screen at the same time, without having to close one to see the next.
I have already used the 'subplot' function, but I also need to use the 'print' command, and the figures are not saved with sufficient quality for proper viewing.

Accepted Answer

Walter Roberson
Walter Roberson on 16 Oct 2024
semilogx(data_resi_inter.PGA1100,delta_ij_inter,'^r');
The x axis is being set to log.
plot([0 0.6],[0 0],'k--','LineWidth',1.0) % dashed line
You ask to plot starting from 0 on a log x axis. That is an implicit request to plot from -infinity (log(0) == -infinity). No line will be drawn when a coordinate is nan or inf.
You need to start your plot from a positive real coordinate.
  8 Comments
Ivan
Ivan on 16 Oct 2024
And if you know anything about the error bars shown in the image, that would also be very helpful.
Sam Chak
Sam Chak on 17 Oct 2024
You can learn more in the documentation of ylabel():
However, plotting error bars is uncommon in my field, as most phenomena can be modeled with deterministic mathematical equations, provided they align with the governing equations of physics. Therefore, insignificant errors are often neglected, as they typically do not pose a threat to human safety or asset value. Moreover, there are predictive and corrective algorithms available as backups.
Have you not found any information about error bars on mathworks.com?

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!