IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

Ajout d'une seconde échelle sur le même axe


Sujet :

MATLAB

  1. #1
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2015
    Messages
    195
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2015
    Messages : 195
    Points : 101
    Points
    101
    Par défaut Ajout d'une seconde échelle sur le même axe
    Bonjour,
    J’ai tracé deux courbes sur le même graphe avec deux différents axes y.
    Je veux ajouter une troisième et je mets sur le même graphe (x3, y3). Je voudrais ajouter une seconde échelle des ordonnées à droite avec une autre couleur et pointillés.
    Merci pour votre aide.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    h=figure('Color',[1 1 1])
    x1 =0:10:500;
    y1=x1;
    yyaxis left
    plot(x1,y1,'r');
    x2=0:10:1000;
    y2=1000:-10:0;
    yyaxis right
    plot(x2,y2,'b');
     
    x3=0:10:1000;
    y3=1500:100:2000;

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 316
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 316
    Points : 52 947
    Points
    52 947
    Par défaut
    Utilise plotyy

  3. #3
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2015
    Messages
    195
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2015
    Messages : 195
    Points : 101
    Points
    101
    Par défaut Ajout d'une seconde échelle sur le même axe
    Merci Jerome Briot

    pourriez-vous me donner comment faire avec l'exemple. plotyy donne un axe à droite et un autre à gauche comme j'ai fait moi pour le premier et la deuxième courbe.


    Un truc comme cité dans l'exemple suivant.

    Merci
    Images attachées Images attachées  

  4. #4
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2019
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Juin 2019
    Messages : 90
    Points : 254
    Points
    254
    Par défaut
    Bonjour,

    le code ci-dessous fait à peu près ce que tu demandes :
    Nom : dvp1.png
Affichages : 2201
Taille : 35,1 Ko

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
     
    % ypa, 30/08/09
     
    % data to be ploted on each axe
    x = linspace(pi, 4*pi, 1e2) ; 
    y2 = sin(x) ;
    y22 = cos(x) ;
    y1 = x.^2 ;
    y3 = exp(x) ;
     
     
    h = figure ;
    delay_x = 0.08 ; % distance between the two left axes
    axeWidth = 0.775 ; % distance between the utmost left and right axes - 0.775 is the standard Matlab value
     
    h1 = axes(h, 'Position', [0.1300+delay_x    0.1100    axeWidth-delay_x    0.8150]) ; % build the first axis
    c_map = h1.ColorOrder ; % save the standard Matlab colormap - though any other could be used
    plot(x, y1, 'Color', c_map(1,:)) ; % plot first ais data
    h1.YAxisLocation = 'left' ; % the axis shoul dbe on the left side of the plot
    h1.YLabel.String = '1st axis' ; % add y-label
    h1.XLabel.String = 'time (p.u.)' ; % add x-label
    h1.YAxis.Color = c_map(1,:) ; % set the color of the y-axis to be the same as that of the plotted line
    h1.XLimMode = 'manual' ; 
    xlim0 = h1.XLim ; % save X-axis limits so that all axes share the same. 
    h1.Box = 'off' ; % show only the bttom and left borders of plotting area
    h1.XGrid = 'on' ; % had a vertical grid
    h1.YGrid = 'on' ; % had a horizontal grid
     
    h2 = axes(h, 'Position', [0.1300+delay_x    0.1100    axeWidth-delay_x    0.8150]) ;
    plot(x, y2, 'Color', c_map(2,:))
    hold on
    plot(x, y22, '--', 'Color', c_map(2,:)) ;
    h2.YAxisLocation = 'right' ;
    h2.YLabel.String = '2nd axis' ;
    h2.XAxis.Visible = 'off' ;
    h2.YAxis.Color = c_map(2,:) ;
    h2.Color='none' ;
    h2.Box = 'off' ;
    h2.XLim = xlim0 ;
     
    h3 = axes(h, 'Position', [0.1300    0.1100    axeWidth    0.8150]) ;
    plot(x, y3, 'Color', c_map(3,:))
    h3.YAxisLocation = 'left' ;
    h3.YLabel.String = '3^{rd} axis' ;
    h3.XAxis.Visible = 'off' ;
    h3.Color='none' ;
    h3.XLim = [xlim0(1)-delay_x/(axeWidth-delay_x)*(xlim0(2)-xlim0(1)), xlim0(2)] ;
    h3.YAxis.Color = c_map(3,:) ;
    h3.Color='none' ;
    h3.Box = 'off' ;

Discussions similaires

  1. Ajout d'une seconde au temps
    Par momo1367 dans le forum Pascal
    Réponses: 12
    Dernier message: 04/01/2008, 17h43
  2. Réponses: 2
    Dernier message: 11/06/2007, 14h51
  3. Réponses: 2
    Dernier message: 10/05/2007, 17h07
  4. Ajout d'une seconde langue S/Windows
    Par akli_agha dans le forum Windows
    Réponses: 2
    Dernier message: 07/12/2006, 14h55
  5. Acquitter une requête POST sur la même connexion
    Par phaby dans le forum Langage
    Réponses: 2
    Dernier message: 18/04/2006, 10h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo