Hello I want to make a plot with two "y" axes. The labels at axis 4 should be the values from axis 2 multiplied by a scale factor (as 3.5). In the example below I draw axis 4 exactly as axis 2. But I could not find a way to multiply its values by 3.5 (e.g.). plot(rnorm(100,30,5)) axis(4) # I'd like to have these values multiplied by a scale factor I will produce plots for different data sets in a looping and y values will vary so I cannot "freeze" axis 4 labels because they (values and scale factor) will vary from plot to plot. Thanks in advance for any help. All the best. Antonio [[alternative HTML version deleted]]
Does the following do what you want?> plot(log2(1:40), sin(1:40)) > yTickPositions <- axTicks(2) > axis(side=4, at=yTickPositions, lab=format(yTickPositions*3.5))Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, May 6, 2017 at 2:50 PM, Antonio Silva <aolinto.lst at gmail.com> wrote:> Hello > > I want to make a plot with two "y" axes. The labels at axis 4 should be the > values from axis 2 multiplied by a scale factor (as 3.5). > > In the example below I draw axis 4 exactly as axis 2. But I could not find > a way to multiply its values by 3.5 (e.g.). > > plot(rnorm(100,30,5)) > axis(4) # I'd like to have these values multiplied by a scale factor > > I will produce plots for different data sets in a looping and y values will > vary so I cannot "freeze" axis 4 labels because they (values and scale > factor) will vary from plot to plot. > > Thanks in advance for any help. All the best. > > Antonio > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Many thanks Bill, that's it! Best wishes Antonio 2017-05-06 20:50 GMT-03:00 William Dunlap <wdunlap at tibco.com>:> Does the following do what you want? > > > plot(log2(1:40), sin(1:40)) > > yTickPositions <- axTicks(2) > > axis(side=4, at=yTickPositions, lab=format(yTickPositions*3.5)) > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Sat, May 6, 2017 at 2:50 PM, Antonio Silva <aolinto.lst at gmail.com> > wrote: > >> Hello >> >> I want to make a plot with two "y" axes. The labels at axis 4 should be >> the >> values from axis 2 multiplied by a scale factor (as 3.5). >> >> In the example below I draw axis 4 exactly as axis 2. But I could not find >> a way to multiply its values by 3.5 (e.g.). >> >> plot(rnorm(100,30,5)) >> axis(4) # I'd like to have these values multiplied by a scale factor >> >> I will produce plots for different data sets in a looping and y values >> will >> vary so I cannot "freeze" axis 4 labels because they (values and scale >> factor) will vary from plot to plot. >> >> Thanks in advance for any help. All the best. >> >> Antonio >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posti >> ng-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > >-- Ant?nio Olinto ?vila da Silva Bi?logo / Ocean?grafo Instituto de Pesca (Fisheries Institute) S?o Paulo, Brasil [[alternative HTML version deleted]]
Hi Antonio, Have a look at twoord.plot (plotrix). It may make your repeated plots easier. Jim On Sun, May 7, 2017 at 7:50 AM, Antonio Silva <aolinto.lst at gmail.com> wrote:> Hello > > I want to make a plot with two "y" axes. The labels at axis 4 should be the > values from axis 2 multiplied by a scale factor (as 3.5). > > In the example below I draw axis 4 exactly as axis 2. But I could not find > a way to multiply its values by 3.5 (e.g.). > > plot(rnorm(100,30,5)) > axis(4) # I'd like to have these values multiplied by a scale factor > > I will produce plots for different data sets in a looping and y values will > vary so I cannot "freeze" axis 4 labels because they (values and scale > factor) will vary from plot to plot. > > Thanks in advance for any help. All the best. > > Antonio > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.