Group Abstract Group Abstract

Message Boards Message Boards

1
|
8.3K Views
|
8 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Plot on two or more axes?

Posted 9 years ago

I know, it's a stupid question. I want to plot two functions y=f1(x) and y=f2(x) within the same diagram. But the y-scales are very different. Hence I want to draw f2(x) on a secondary y-axes. Having the y-axes for f1 on the left and the y-axes for f2 on the right. This is standard in all drawing programs. But I cannot find within the documentation of Wolfram Language, how to do that.

POSTED BY: Werner Geiger
8 Replies
Posted 9 years ago

Wouldn't it be nice if our friends at Wolfram would sit down with a collection of journals -- Science, Nature, IEEE Spectrum, Physical Review, etc -- and see that Mathematica was able to produce the plots needed, right out of the box?

POSTED BY: David Keith

I think it already does the fast majority of the plots. To support 'all' of them would become cumbersome I guess; too many variations for specific fields et cetera. Fortunately Mathematica can customize basically any detail of the plot through options which makes it possible to create many different plots, including the one that the OP wants; it's simply scaling the 'second' plot, and replacing some ticks.

POSTED BY: Sander Huisman
Posted 9 years ago

Sorry, Sander, but what is an "OP"? (I am German).

Meanwhile I read all the links for plotting on two axes. I would not call that "simple", but pretty tedious. And not the kind of programming one likes to do if one has to solve a real problem.

POSTED BY: Werner Geiger

OP stands for 'original poster'; i.e. the person who started the thread; you! Most of the time people use these kinds of plots to look for some correlation; (why else would you combine two different plots in to one?). I favour plotting one versus the other or plotting the two data above each other (two stacked plots). Sometimes there are, however, space-requirements of certain journals that forces you into making these kinds of plots unfortunately.

It is a bit tedious, but I would be pretty happy if the biggest obstacle in my data-analysis is giving a frame-tick specification... The links that Vitaliy posted are kind of what I said (replacing the ticks and rescaling some data) except for the Overlay solution. That one returns an 'Overlay' object, not a Graphics object which might not be handy as you can't use an Overlay in Show. So chose wisely...

POSTED BY: Sander Huisman
Posted 9 years ago

Thanks, Sander, for information.

POSTED BY: Werner Geiger
Posted 9 years ago

Thank you very much Vitaliy. I think, your links will solve my two-axes-problem (shame on me that I could not find them myself). Overlay seems to be the easiest way.

But isn't it a bit strange, that the Wolfram Language cannot do that by itself with a simple Plot-option like UseAxes->{Primary,Secondary} as for example Excel does.

POSTED BY: Werner Geiger

I'm afraid you have to do that manually:

Rescaling your 'second' plot, and then 'faking' the right ticks in the FrameTicks specification.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard