![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/678068/image.png)
plotting bar graph using matlab
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Seismic D
am 8 Jul. 2021
Bearbeitet: Seismic D
am 8 Jul. 2021
Hii experts i want to make a beautiful bar plot using the attached data(data.txt). On the x axis i want to plot years such as 2007, 2008 etc from the first column data and on the y axis corresponding second column data.Most importantly, i want to mention only the year such as 2007 2008 only once along the x axis as on the x axis labels doesnot visible due to huge data.
my sample data is
2008-05-24 3.5
2008-05-25 4.3
2008-06-11 3.7
2008-06-14 3.8
0 Kommentare
Akzeptierte Antwort
Akira Agata
am 8 Jul. 2021
How about using a stem plot?
The following is an example:
tt = readtimetable('data.txt');
figure
stem(tt.Time, tt.Var1,'Marker','none')
xlabel('Years','FontSize',12)
ylabel('Amplitude','FontSize',12)
grid on
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/678068/image.png)
0 Kommentare
Weitere Antworten (1)
Simon Chan
am 8 Jul. 2021
Add xaxis limit:
xlim([datetime(2007,1,1) datetime(2016,12,31)])
0 Kommentare
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots 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!