Plot with two different y axis (text-data)

조회 수: 3 (최근 30일)
Rachele Franceschini
Rachele Franceschini 2022년 4월 12일
댓글: Rachele Franceschini 2022년 4월 13일
I have one table with several regions, and the values distribution for each year (from 2010 to 2019).
I would like to get line plot with to y-axis left regions name, to right values. While x-axis there are years.
t = readtable('Cartel1.xlsx')
It's possible?
for example, creating barth (stacked) but using lines

채택된 답변

Chunru
Chunru 2022년 4월 12일
편집: Chunru 2022년 4월 12일
t = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/961730/Cartel1.xlsx');
head(t)
ans = 8×11 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11 _____________ _______ _______ _______ ______ ______ _______ _______ _______ _______ _______ {'regions_p'} 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 {'A' } 0.62891 1.1046 1.3891 1.864 1.5899 0.70993 0.66656 0.67802 0.74008 0.62891 {'B' } 0.56074 0.53844 0.97474 1.3421 1.0435 1.1377 1.2181 0.83779 1.2789 1.068 {'C' } 0.88687 0.93951 0.98286 1.1213 1.0318 1.177 0.99839 0.73448 1.2059 0.92194 {'D' } 0.93823 0.80934 0.99234 1.2517 1.0988 0.99212 0.95762 0.728 1.1276 1.1043 {'E' } 0.6829 0.80186 0.94871 1.2642 1.4407 0.86883 0.96912 0.79355 0.99117 1.239 {'F' } 0.63041 0.87128 1.0953 1.0785 1.4302 0.73926 0.96106 0.98217 1.0026 1.2092 {'G' } 0.33694 0.89674 1.0714 1.3123 1.3262 0.91323 0.95403 0.79544 1.213 1.1807
plot(t{1, 2:end}', t{2:end, 2:end}' );
legend(t.Var1{2:end}, 'location', 'eastoutside')
  댓글 수: 1
Rachele Franceschini
Rachele Franceschini 2022년 4월 13일
It is possible to get for each line, a different color?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by