ads legend to plot

4 次查看(过去 30 天)
Aaron Petersen
Aaron Petersen 2022-4-14
回答: Lokesh 2023-9-26
Hallo, meinMatlab möchte diese Legende nicht darstsellen und ich finde den Fehler nicht.
Legendtitel = {'Messung Flussdichte','SIM Flussdichte','FEM Flussdichte','Analyse Flussdichte','Messung Abreiskraft','SIM Abreiskraft','FEM Abreiskraft','Analyse Abreiskraft'}
legend(Legendtitel)
Danke im Voraus!
Grüße, Aaron
  1 个评论
Aaron Petersen
Aaron Petersen 2022-4-14
yyaxis left
ylabel('Flussdichte /mT')
plot(Magnete.AnzMagnete,Magnete.Flussdichte_mT,'-');
yyaxis right
ylabel('Abreiskraft /N')
plot(Magnete.AnzMagnete,Magnete.Abreiskraft_N,'-');
Und warum wird mir hier keine yAchsenbeschriftung ausgegeben?

请先登录,再进行评论。

回答(1 个)

Lokesh
Lokesh 2023-9-26
Hi Aaron,
I understand from your query that your MATLAB code is not displaying the legend and ylabel correctly.
However, there are a few issues with the code you provided. The possible reasons for the issue and their fixes are mentioned below:
  • The “legend” and “ylabel” functions are used to display legend and plot for the previously plotted data series. So, ensure that you have plotted the data before calling the legend and ylabel function.
I have provided an example code snippet below that adds ylabel and legend to the plot:
yyaxis left
plot (Magnete.AnzMagnete,Magnete.Flussdichte_mT,'-');
ylabel('Flussdichte /mT')
yyaxis right
plot(Magnete.AnzMagnete,Magnete.Abreiskraft_N,'-');
ylabel('Abreiskraft /N')
Legendtitel = {'Messung Flussdichte', 'Messung Abreiskraft'}
legend(Legendtitel)
You can refer to the below mentioned documentation to know more about the usage of “ylabel” and “legend”:
Hope this helps in resolving the issue.
Best Regards,
Lokesh

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!