Plotting curves of different orders of magnitudes on the same graph

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












I want to plot



Plot[Exp[x],Sin[x],x,0,10]


The issue is that Sin[x] and Exp[x] are not of the same order of magnitude, so we do not see Sin[x]. Therefore, I would like to set different y-axis but on the same graph. For Exp[x], the y axis would go from 0 to 25000 and for Sin[x] from -1 to 1. How can I do that ?










share|improve this question























  • Why do you need to plot curves with widely-varying ranges together?
    – J. M. is somewhat okay.♦
    5 hours ago






  • 1




    I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
    – J.A
    5 hours ago










  • How about LogPlot?
    – Î‘λέξανδρος Ζεγγ
    2 hours ago






  • 1




    @ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
    – Michael Seifert
    1 hour ago














up vote
5
down vote

favorite












I want to plot



Plot[Exp[x],Sin[x],x,0,10]


The issue is that Sin[x] and Exp[x] are not of the same order of magnitude, so we do not see Sin[x]. Therefore, I would like to set different y-axis but on the same graph. For Exp[x], the y axis would go from 0 to 25000 and for Sin[x] from -1 to 1. How can I do that ?










share|improve this question























  • Why do you need to plot curves with widely-varying ranges together?
    – J. M. is somewhat okay.♦
    5 hours ago






  • 1




    I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
    – J.A
    5 hours ago










  • How about LogPlot?
    – Î‘λέξανδρος Ζεγγ
    2 hours ago






  • 1




    @ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
    – Michael Seifert
    1 hour ago












up vote
5
down vote

favorite









up vote
5
down vote

favorite











I want to plot



Plot[Exp[x],Sin[x],x,0,10]


The issue is that Sin[x] and Exp[x] are not of the same order of magnitude, so we do not see Sin[x]. Therefore, I would like to set different y-axis but on the same graph. For Exp[x], the y axis would go from 0 to 25000 and for Sin[x] from -1 to 1. How can I do that ?










share|improve this question















I want to plot



Plot[Exp[x],Sin[x],x,0,10]


The issue is that Sin[x] and Exp[x] are not of the same order of magnitude, so we do not see Sin[x]. Therefore, I would like to set different y-axis but on the same graph. For Exp[x], the y axis would go from 0 to 25000 and for Sin[x] from -1 to 1. How can I do that ?







plotting visualization






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 30 mins ago









Community♦

1




1










asked 5 hours ago









J.A

1414




1414











  • Why do you need to plot curves with widely-varying ranges together?
    – J. M. is somewhat okay.♦
    5 hours ago






  • 1




    I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
    – J.A
    5 hours ago










  • How about LogPlot?
    – Î‘λέξανδρος Ζεγγ
    2 hours ago






  • 1




    @ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
    – Michael Seifert
    1 hour ago
















  • Why do you need to plot curves with widely-varying ranges together?
    – J. M. is somewhat okay.♦
    5 hours ago






  • 1




    I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
    – J.A
    5 hours ago










  • How about LogPlot?
    – Î‘λέξανδρος Ζεγγ
    2 hours ago






  • 1




    @ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
    – Michael Seifert
    1 hour ago















Why do you need to plot curves with widely-varying ranges together?
– J. M. is somewhat okay.♦
5 hours ago




Why do you need to plot curves with widely-varying ranges together?
– J. M. is somewhat okay.♦
5 hours ago




1




1




I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
– J.A
5 hours ago




I have a case when I want to visualize the data and the log of the data. The curve is supposed to be an exponential at the beginning and vary linearly at the end. I want to see a linear evolution at the beginning with the log of the data, a linear evolution at the end with the data, and a transition area. I asked my question in a simple way, since the data is pretty big and that it's a general question
– J.A
5 hours ago












How about LogPlot?
– Î‘λέξανδρος Ζεγγ
2 hours ago




How about LogPlot?
– Î‘λέξανδρος Ζεγγ
2 hours ago




1




1




@ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
– Michael Seifert
1 hour ago




@ΑλέξανδροςΖεγγ: That won't work so well for a function that becomes negative, like Sin[x] does. (There are ways around this, of course.)
– Michael Seifert
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
6
down vote













A slightly modified version using Overlay.



combine[data1_, data2_] := Overlay[ListLinePlot[data1,
Frame -> True, True, False, False,
FrameLabel -> "x1", "y1", LabelStyle -> Directive[12, Blue],
PlotStyle -> Blue, PlotRange -> All,
ImagePadding -> 50, 50, 40, 40],
ListLinePlot[data2, Frame -> False, False, True, True,
FrameTicks -> All, FrameLabel -> None, "y2", None, "x2",
LabelStyle -> Directive[12, Red], PlotStyle -> Red, Dashed,
PlotRange -> All, ImagePadding -> 50, 50, 40, 40],
Alignment -> Center]

data1 = Table[x, Sin[x], x, 0, 10, 0.01];
data2 = Table[x, Exp[x], x, -5, 5, 0.01];
combine[data1, data2]


enter image description here



One advantage here is that you can use any range for x and y.



You can use Plot as well in the combine and modify the appearance.






share|improve this answer






















  • +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
    – Michael Seifert
    1 hour ago


















up vote
3
down vote













Multiply, Sin[x] by, say, 1000 and rescale the right axis:



Plot[Exp[x], 1000 Sin[x], x, 0, 10, Frame -> True, 
FrameTicks -> Automatic, Charting`FindTicks[-1000, 1000, -1, 1],
Automatic, Automatic,
PlotLegends -> "Expressions"]


enter image description here






share|improve this answer






















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183357%2fplotting-curves-of-different-orders-of-magnitudes-on-the-same-graph%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote













    A slightly modified version using Overlay.



    combine[data1_, data2_] := Overlay[ListLinePlot[data1,
    Frame -> True, True, False, False,
    FrameLabel -> "x1", "y1", LabelStyle -> Directive[12, Blue],
    PlotStyle -> Blue, PlotRange -> All,
    ImagePadding -> 50, 50, 40, 40],
    ListLinePlot[data2, Frame -> False, False, True, True,
    FrameTicks -> All, FrameLabel -> None, "y2", None, "x2",
    LabelStyle -> Directive[12, Red], PlotStyle -> Red, Dashed,
    PlotRange -> All, ImagePadding -> 50, 50, 40, 40],
    Alignment -> Center]

    data1 = Table[x, Sin[x], x, 0, 10, 0.01];
    data2 = Table[x, Exp[x], x, -5, 5, 0.01];
    combine[data1, data2]


    enter image description here



    One advantage here is that you can use any range for x and y.



    You can use Plot as well in the combine and modify the appearance.






    share|improve this answer






















    • +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
      – Michael Seifert
      1 hour ago















    up vote
    6
    down vote













    A slightly modified version using Overlay.



    combine[data1_, data2_] := Overlay[ListLinePlot[data1,
    Frame -> True, True, False, False,
    FrameLabel -> "x1", "y1", LabelStyle -> Directive[12, Blue],
    PlotStyle -> Blue, PlotRange -> All,
    ImagePadding -> 50, 50, 40, 40],
    ListLinePlot[data2, Frame -> False, False, True, True,
    FrameTicks -> All, FrameLabel -> None, "y2", None, "x2",
    LabelStyle -> Directive[12, Red], PlotStyle -> Red, Dashed,
    PlotRange -> All, ImagePadding -> 50, 50, 40, 40],
    Alignment -> Center]

    data1 = Table[x, Sin[x], x, 0, 10, 0.01];
    data2 = Table[x, Exp[x], x, -5, 5, 0.01];
    combine[data1, data2]


    enter image description here



    One advantage here is that you can use any range for x and y.



    You can use Plot as well in the combine and modify the appearance.






    share|improve this answer






















    • +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
      – Michael Seifert
      1 hour ago













    up vote
    6
    down vote










    up vote
    6
    down vote









    A slightly modified version using Overlay.



    combine[data1_, data2_] := Overlay[ListLinePlot[data1,
    Frame -> True, True, False, False,
    FrameLabel -> "x1", "y1", LabelStyle -> Directive[12, Blue],
    PlotStyle -> Blue, PlotRange -> All,
    ImagePadding -> 50, 50, 40, 40],
    ListLinePlot[data2, Frame -> False, False, True, True,
    FrameTicks -> All, FrameLabel -> None, "y2", None, "x2",
    LabelStyle -> Directive[12, Red], PlotStyle -> Red, Dashed,
    PlotRange -> All, ImagePadding -> 50, 50, 40, 40],
    Alignment -> Center]

    data1 = Table[x, Sin[x], x, 0, 10, 0.01];
    data2 = Table[x, Exp[x], x, -5, 5, 0.01];
    combine[data1, data2]


    enter image description here



    One advantage here is that you can use any range for x and y.



    You can use Plot as well in the combine and modify the appearance.






    share|improve this answer














    A slightly modified version using Overlay.



    combine[data1_, data2_] := Overlay[ListLinePlot[data1,
    Frame -> True, True, False, False,
    FrameLabel -> "x1", "y1", LabelStyle -> Directive[12, Blue],
    PlotStyle -> Blue, PlotRange -> All,
    ImagePadding -> 50, 50, 40, 40],
    ListLinePlot[data2, Frame -> False, False, True, True,
    FrameTicks -> All, FrameLabel -> None, "y2", None, "x2",
    LabelStyle -> Directive[12, Red], PlotStyle -> Red, Dashed,
    PlotRange -> All, ImagePadding -> 50, 50, 40, 40],
    Alignment -> Center]

    data1 = Table[x, Sin[x], x, 0, 10, 0.01];
    data2 = Table[x, Exp[x], x, -5, 5, 0.01];
    combine[data1, data2]


    enter image description here



    One advantage here is that you can use any range for x and y.



    You can use Plot as well in the combine and modify the appearance.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 hours ago

























    answered 3 hours ago









    Sumit

    11.5k21854




    11.5k21854











    • +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
      – Michael Seifert
      1 hour ago

















    • +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
      – Michael Seifert
      1 hour ago
















    +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
    – Michael Seifert
    1 hour ago





    +1 for the coding ingenuity, but honestly, for me this just reinforces the idea that a small multiple chart is often the way to go.
    – Michael Seifert
    1 hour ago











    up vote
    3
    down vote













    Multiply, Sin[x] by, say, 1000 and rescale the right axis:



    Plot[Exp[x], 1000 Sin[x], x, 0, 10, Frame -> True, 
    FrameTicks -> Automatic, Charting`FindTicks[-1000, 1000, -1, 1],
    Automatic, Automatic,
    PlotLegends -> "Expressions"]


    enter image description here






    share|improve this answer


























      up vote
      3
      down vote













      Multiply, Sin[x] by, say, 1000 and rescale the right axis:



      Plot[Exp[x], 1000 Sin[x], x, 0, 10, Frame -> True, 
      FrameTicks -> Automatic, Charting`FindTicks[-1000, 1000, -1, 1],
      Automatic, Automatic,
      PlotLegends -> "Expressions"]


      enter image description here






      share|improve this answer
























        up vote
        3
        down vote










        up vote
        3
        down vote









        Multiply, Sin[x] by, say, 1000 and rescale the right axis:



        Plot[Exp[x], 1000 Sin[x], x, 0, 10, Frame -> True, 
        FrameTicks -> Automatic, Charting`FindTicks[-1000, 1000, -1, 1],
        Automatic, Automatic,
        PlotLegends -> "Expressions"]


        enter image description here






        share|improve this answer














        Multiply, Sin[x] by, say, 1000 and rescale the right axis:



        Plot[Exp[x], 1000 Sin[x], x, 0, 10, Frame -> True, 
        FrameTicks -> Automatic, Charting`FindTicks[-1000, 1000, -1, 1],
        Automatic, Automatic,
        PlotLegends -> "Expressions"]


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 4 hours ago

























        answered 5 hours ago









        kglr

        164k8188388




        164k8188388



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183357%2fplotting-curves-of-different-orders-of-magnitudes-on-the-same-graph%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery