Subdivide a figure with a grid (as in Timescope)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The MATLAB function timescope, by using LayoutDimensions, can subdivide the generated figure into equal parts (one for each subplot), separated by lines (see attached: timescope_example). I would like to recreate this same feature. Currently, I am using a combination of both plot and subplot to obtain a similar visual appearance (which is good enough for my purposes), but I cannot recreate the figure-grid-lines (see attached: plot_example).
So, how can this feature of timescope be replicated?
P.S. Maybe it could be done by using uipanel, but I am too unfamiliar with it to know how to do it.
2 commentaires
Dyuman Joshi
le 19 Fév 2024
Modifié(e) : Dyuman Joshi
le 19 Fév 2024
You can turn the clipping off and draw lines accordingly.
A direct implementation for vertical lines -
Réponse acceptée
Mann Baidi
le 19 Fév 2024
Modifié(e) : Mann Baidi
le 19 Fév 2024
Hi Luca,
I understand that you would like to separate the subplots generated using "plot" with dividing lines. Yes, it can be done using the 'uipanel'. uipanel divides the subplots by lines same as the 'timescope'.
For generating plots in 'uipanel' using plot and subplot, you can refer to the following example.
% Define the number of panels and the layout
numPanels = 4;
rows = 2;
cols = 2;
% Create a figure window
figure;
% Create panels and axes for each plot
for i = 1:numPanels
panel = uipanel('Title', sprintf('Panel %d', i), 'Position', [(mod(i-1, cols))/cols, 1-(ceil(i/cols))/rows, 1/cols, 1/rows]);
ax = axes('Parent', panel);
% Plot data in each panel
if i==1
plot(1:100);
elseif i==2
plot(sin(1:100))
elseif i==3
plot(cos(1:100))
elseif i==4
plot(1:10)
end
hold on;
% Customize axes, labels, etc. as needed
end
You can update your plot functions as per your requirements.
Feel free to explore more about 'uipanel' using the following link:
Hope this will help is resolving your query!
Plus de réponses (1)
Matt J
le 19 Fév 2024
Modifié(e) : Matt J
le 19 Fév 2024
Something like this, perhaps?
t=tiledlayout(2,2);
for i=1:4, nexttile(t), plot(rand(1,4)); grid on; end
background=axes('Position', t.OuterPosition,'XLim',[0,1],'YLim',[0,1],'Visible','off');
h=gcf; h.Children=flip(h.Children);
xline(background, 0.5,'r');
yline(background, [0.96,0.48,0.52],'r');
2 commentaires
Matt J
le 19 Fév 2024
If the code could be made flexible enough to automatically accomodate an arbitrary number of "panels" (let's call them that way), it would be great!
It would be quite easy for you to do that.
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!