How display a log space bar figure ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mallouli Marwa
am 25 Jan. 2020
Beantwortet: Akira Agata
am 25 Jan. 2020
Hi I have plotted a bar figure but I want that the y axis log space.
Please can you rectify my code.
clear all
clc
maxV_l = [0.015232 0.020273 0.0069196 0.012027 0.010313 0.012567 0.014836 0.015071 0.016182 0.018388 0.013878];
maxV_m = [12.911 15.205 6.6378 10.659 9.3996 11.026 12.564 12.685 13.418 14.511 12.082];
maxV_h = [ 166.73 138.81 167.74 148.64 146.5 155.99 149.72 162.55 172.41 166.32 154.67];
% Create a vertical bar chart using the bar function
figure (1)
bar(1:11, [maxV_l' maxV_m' maxV_h'],1)
% Set the axis limits
set(gca,'xticklabel',{'PZT-5A','PZT-5H','PZT-7A','PZT-4','PZT-8','APC-8740','APC-850','SONOX-P504','SONOX-P508','PIC-151','PIC-255'});
% Add title and axis labels
xlabel('Material')
ylabel('|Peak Voltage| [V/g]')
% Add a legend
legend('Rl=100\Omega', 'Rl=100k\Omega', 'Rl=10M\Omega')
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Akira Agata
am 25 Jan. 2020
Please set YScale property of the axes to 'log'.
The following is an example.
maxV_l = [0.015232 0.020273 0.0069196 0.012027 0.010313 0.012567 0.014836 0.015071 0.016182 0.018388 0.013878];
maxV_m = [12.911 15.205 6.6378 10.659 9.3996 11.026 12.564 12.685 13.418 14.511 12.082];
maxV_h = [ 166.73 138.81 167.74 148.64 146.5 155.99 149.72 162.55 172.41 166.32 154.67];
% Create a vertical bar chart using the bar function
figure
bar([maxV_l' maxV_m' maxV_h'],1)
ax = gca;
ax.XTickLabel =...
{'PZT-5A','PZT-5H','PZT-7A','PZT-4','PZT-8','APC-8740','APC-850','SONOX-P504','SONOX-P508','PIC-151','PIC-255'};
ax.XTickLabelRotation = 45;
ax.YScale = 'log';
ax.YLim(2) = 1e4; % To make additional space for a legend
% Add title and axis labels
xlabel('Material','FontSize',12)
ylabel('|Peak Voltage| [V/g]','FontSize',12)
% Add a legend
legend('Rl=100\Omega', 'Rl=100k\Omega', 'Rl=10M\Omega')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!