Problem with legend command

I have a problem with the legend. When I use the legend command, you don't see the box and colored lines on the plot. You only see the writings. I can't fix it, does anyone know what I can do?

Antworten (2)

RITAM BASU
RITAM BASU am 4 Nov. 2022

0 Stimmen

for turning on the box, try:
legend('boxon')

2 Kommentare

Amin Damrah
Amin Damrah am 5 Nov. 2022
I tried but it doesn't work
Amin Damrah
Amin Damrah am 5 Nov. 2022
this is my problem.

Melden Sie sich an, um zu kommentieren.

Star Strider
Star Strider am 4 Nov. 2022

0 Stimmen

This is a known problem with certain AMD graphics drivers, although it was fixed a while ago.
Go to the GeForce Experience website. It has a downloadable app that will automatically find your videocard and download the correct current driver for it.

9 Kommentare

Amin Damrah
Amin Damrah am 5 Nov. 2022
I try and let you know if it works
Star Strider
Star Strider am 5 Nov. 2022
If you have an AMD graphics card and haven’t updated the drivers in a few years, the update should colve it.
Amin Damrah
Amin Damrah am 5 Nov. 2022
I think this doesn't solve the Matlab Legneda problem.
Star Strider
Star Strider am 5 Nov. 2022
It you have an AMD graphics card with a driver that has not been updated in a few years, it should solve it.
If you have updated the driver and are still getting the problem, please post your code and any necesary data needed to run it.
Amin Damrah
Amin Damrah am 5 Nov. 2022
I gave a simple example.
y1 = rand(3);
ax1 = nexttile;
plot(y1)
legend(ax1,{'Line 1','Line 2','Line 3'})
It works correctly here —
y1 = rand(3);
ax1 = nexttile;
plot(y1)
legend(ax1,{'Line 1','Line 2','Line 3'})
Do you have an AMD graphics card? If so, did you upgrade to the latest driver?
Also, this should work —
clf
y1 = rand(3);
opengl('software') % Will Be Removed In An Upsoming Release, Still Works
ax1 = nexttile;
plot(y1)
legend(ax1,{'Line 1','Line 2','Line 3'})
If the opengl call solves the problem, and you have an AMD graphics card, the driver is the problem. Update it.
See the documentation on Resolving Low-Level Graphics Issues and rendererinfo.
.
Amin Damrah
Amin Damrah am 6 Nov. 2022
opengl('software')
with this, it is correct. Thank you.
Star Strider
Star Strider am 6 Nov. 2022
That confirms that you still need to update the driver. Tha AMD software that I linked to makes that straightforward.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Objects finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 4 Nov. 2022

Kommentiert:

am 6 Nov. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by