Why colororder function does not work with ylim? (2024)

10 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Ludovica Varriale am 9 Okt. 2023

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim

Kommentiert: Dyuman Joshi am 10 Okt. 2023

Akzeptierte Antwort: Dyuman Joshi

In MATLAB Online öffnen

Hello everybody,

I have a problem with my Matlab code. I would like to make a 2D plot with two y-axis with different axis limits. The created a proper function for the colors and I used them using the colororder function. However, it does not work with I wrote ylim function.

Do you know why?

I hope you can help me :)

Here my code:

figure

hold on

fontsize(12,"points");

x=[0,6,24,48,72];

xlabel('Time [h]');

yyaxis left

ylabel('Sugars [g/L]');

Glu1=[20.68,23.35,5.41,0.54,0];

errGlu1=[0.77,2.07,0.69,0.12,0];

Fru1=[5.19,5.55,2.07,0.93,0.78];

ylim([0 25])

yyaxis right

ylabel('Products [g/L]');

Et1=[0,0.16,7.51,9.37,8.20];

errEt1=[0,0.02,0.34,0.71,0.42];

Gly1=[0,0.2,0.3,0.36,0.37];

errGly1=[0,0.01,0.03,0.03,0.04];

ylim([0 12]);

plot(x,Glu1,'^-','LineWidth',2);

plot(x,Fru1,'^-','LineWidth',2);

plot(x,Et1,'v-', 'LineWidth',2);

plot(x,Gly1,'v-','LineWidth',2);

errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');

Why colororder function does not work with ylim? (2)

errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');

Unrecognized function or variable 'errFru1'.

errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');

errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');

newcolors = [0.83 0.14 0.14

1.00 0.54 0.00

0.47 0.25 0.80

0.25 0.80 0.54];

colororder(newcolors)

hold off

4 Kommentare

2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden

Dyuman Joshi am 9 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915704

There is an undefined variable in your code, see above.

Also, specify which plots you want to draw with the left y-axis and which ones with the right y-axis.

Ludovica Varriale am 9 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915729

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915729

Hi,

thank you very much for you reply. This should be the correct code (sorry for the mistake).

hold on

fontsize(12,"points");

x=[0,6,24,48,72];

xlabel('Time [h]');

yyaxis left

ylabel('Sugars [g/L]');

Glu1=[20.68,23.35,5.41,0.54,0];

errGlu1=[0.77,2.07,0.69,0.12,0];

Fru1=[5.19,5.55,2.07,0.93,0.78];

errFru1= [0.13,0.57,0.41,0.14,0.06];

ylim([0 25])

yyaxis right

ylabel('Products [g/L]');

Et1=[0,0.16,7.51,9.37,8.20];

errEt1=[0,0.02,0.34,0.71,0.42];

Gly1=[0,0.2,0.3,0.36,0.37];

errGly1=[0,0.01,0.03,0.03,0.04];

ylim([0 12]);

plot(x,Glu1,'^-','LineWidth',2);

plot(x,Fru1,'^-','LineWidth',2);

plot(x,Et1,'v-', 'LineWidth',2);

plot(x,Gly1,'v-','LineWidth',2);

errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');

errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');

errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');

errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');

newcolors = [0.83 0.14 0.14

1.00 0.54 0.00

0.47 0.25 0.80

0.25 0.80 0.54];

colororder(newcolors)

hold off

I would need on the y axis left: Glu1 and Fru1 with the respective errorbars, on the right: Et1 and Gly1 with the respective errorbars.

Thank you !

Dyuman Joshi am 9 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915799

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915799

Do you want to colors the individual plots according to the newcolors array?

If not, please specify the output that you want to obtain.

Ludovica Varriale am 9 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915814

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2915814

I would like to have a plot with 4 lines with the different colors specified in the array "newcolors".

As you can see, the problem is that the beginning of the red line is not visible because of the limits I guess.

es. Why colororder function does not work with ylim? (7)

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Akzeptierte Antwort

Dyuman Joshi am 9 Okt. 2023

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#answer_1329449

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#answer_1329449

In MATLAB Online öffnen

Note that in using ylim([0 25]) for the left yaxis, the upper cap of an errorbar data point is not visible. Adjust according to requirements.

%Data

x=[0,6,24,48,72];

Glu1=[20.68,23.35,5.41,0.54,0];

errGlu1=[0.77,2.07,0.69,0.12,0];

Fru1=[5.19,5.55,2.07,0.93,0.78];

errFru1= [0.13,0.57,0.41,0.14,0.06];

Et1=[0,0.16,7.51,9.37,8.20];

errEt1=[0,0.02,0.34,0.71,0.42];

Gly1=[0,0.2,0.3,0.36,0.37];

errGly1=[0,0.01,0.03,0.03,0.04];

figure

hold on

xlabel('Time [h]');

fontsize(12,"points");

yyaxis left

ylabel('Sugars [g/L]');

plot(x,Glu1,'^-','LineWidth',2);

plot(x,Fru1,'^-','LineWidth',2);

errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');

errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');

ylim([0 25])

%Colorder for the left side

newcolors1 = [0.83 0.14 0.14

1.00 0.54 0.00];

colororder(newcolors1)

yyaxis right

ylabel('Products [g/L]');

plot(x,Et1,'v-', 'LineWidth',2);

plot(x,Gly1,'v-','LineWidth',2);

errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');

errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');

ylim([0 12]);

%Colorder for the right side

newcolors2 = [0.47 0.25 0.80

0.25 0.80 0.54];

colororder(newcolors2)

hold off

Why colororder function does not work with ylim? (9)

Also, you can also specify the color of a line plot individually without needing to use colororder(), like you have done for the errorbars, as follows -

%Data

x=[0,6,24,48,72];

Glu1=[20.68,23.35,5.41,0.54,0];

errGlu1=[0.77,2.07,0.69,0.12,0];

Fru1=[5.19,5.55,2.07,0.93,0.78];

errFru1= [0.13,0.57,0.41,0.14,0.06];

Et1=[0,0.16,7.51,9.37,8.20];

errEt1=[0,0.02,0.34,0.71,0.42];

Gly1=[0,0.2,0.3,0.36,0.37];

errGly1=[0,0.01,0.03,0.03,0.04];

%Colors to be used for line plots

c = [0.83 0.14 0.14

1.00 0.54 0.00

0.47 0.25 0.80

0.25 0.80 0.54];

figure

hold on

xlabel('Time [h]');

fontsize(12,"points");

yyaxis left

ylabel('Sugars [g/L]');

plot(x,Glu1,'^-','LineWidth',2,'Color',c(1,:));

plot(x,Fru1,'^-','LineWidth',2,'Color',c(2,:));

errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');

errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');

ylim([0 25])

yyaxis right

ylabel('Products [g/L]');

plot(x,Et1,'v-', 'LineWidth',2,'Color',c(3,:));

plot(x,Gly1,'v-','LineWidth',2,'Color',c(4,:));

errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');

errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');

ylim([0 12]);

hold off

Why colororder function does not work with ylim? (10)

2 Kommentare

Keine anzeigenKeine ausblenden

Ludovica Varriale am 10 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2916654

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2916654

Verschoben: Dyuman Joshi am 10 Okt. 2023

Dear Dyuman Joshi,

thank you a lot for your help! Now the script works as I want!!!

Best regards,

Ludovica Varriale

Dyuman Joshi am 10 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2916659

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2030959-why-colororder-function-does-not-work-with-ylim#comment_2916659

You are welcome!

If my answer solved your problem, please consider accepting the answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABLanguage FundamentalsData TypesDates and TimeCalendar

Mehr zu Calendar finden Sie in Help Center und File Exchange

Tags

  • plot
  • coloroder

Produkte

  • MATLAB

Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by Why colororder function does not work with ylim? (13)

Why colororder function does not work with ylim? (14)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Kontakt zu Ihrer lokalen Niederlassung

Why colororder function does not work with ylim? (2024)
Top Articles
Live Webcam Calypso Resort Towers, Panama City Beach, Florida
Calypso Beach (Griechenland / Rhodos
Mickey Moniak Walk Up Song
Craigslist San Francisco Bay
Menards Thermal Fuse
Pollen Count Centreville Va
Kathleen Hixson Leaked
Jeremy Corbell Twitter
Retro Ride Teardrop
7.2: Introduction to the Endocrine System
Ribbit Woodbine
41 annonces BMW Z3 occasion - ParuVendu.fr
Fcs Teamehub
Infinite Campus Parent Portal Hall County
Tiger Island Hunting Club
General Info for Parents
The Witcher 3 Wild Hunt: Map of important locations M19
Equipamentos Hospitalares Diversos (Lote 98)
Craigslist In Flagstaff
Craigslist Mt Pleasant Sc
Rugged Gentleman Barber Shop Martinsburg Wv
Jet Ski Rental Conneaut Lake Pa
Ein Blutbad wie kein anderes: Evil Dead Rise ist der Horrorfilm des Jahres
Culver's Flavor Of The Day Taylor Dr
The Ultimate Guide to Extras Casting: Everything You Need to Know - MyCastingFile
LCS Saturday: Both Phillies and Astros one game from World Series
Myql Loan Login
Inkwell, pen rests and nib boxes made of pewter, glass and porcelain.
D2L Brightspace Clc
Temu Seat Covers
Medline Industries, LP hiring Warehouse Operator - Salt Lake City in Salt Lake City, UT | LinkedIn
Democrat And Chronicle Obituaries For This Week
Cinema | Düsseldorfer Filmkunstkinos
San Jac Email Log In
The Creator Showtimes Near Baxter Avenue Theatres
How to Use Craigslist (with Pictures) - wikiHow
Pnc Bank Routing Number Cincinnati
Supermarkt Amsterdam - Openingstijden, Folder met alle Aanbiedingen
THE 10 BEST Yoga Retreats in Konstanz for September 2024
Family Fare Ad Allendale Mi
Build-A-Team: Putting together the best Cathedral basketball team
Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
Final Fantasy 7 Remake Nexus
Simnet Jwu
Lyndie Irons And Pat Tenore
Pathfinder Wrath Of The Righteous Tiefling Traitor
Penny Paws San Antonio Photos
How To Get To Ultra Space Pixelmon
Frontier Internet Outage Davenport Fl
Causeway Gomovies
28 Mm Zwart Spaanplaat Gemelamineerd (U999 ST9 Matte | RAL9005) Op Maat | Zagen Op Mm + ABS Kantenband
Secondary Math 2 Module 3 Answers
Latest Posts
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 5843

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.