uses and abuses of logarithmic axes - amazon s3 · logarithmic axes cannot contain zero or negative...

13
1 The Use and Abuse of Logarithmic Axes Harvey J. Motulsky [email protected] © 2009, GraphPad Software, Inc. June 2009 Most graphing programs can plot logarithmic axes, which are commonly used and abused. This article explains the principles behind logarithmic axes, so you can make wise choices about when to use them and when to avoid them. What is a logarithmic axis? A logarithmic axis changes the scale of an axis. The two graphs below show the same two data sets, plotted on different axes. The graph on the left has a linear (ordinary) axis. The difference between every pair of ticks is consistent (2000 in this example). The graph on the right has a logarithmic axis. The difference between every pair of ticks is not consistent. From the bottom tick (0.1) to the next tick is a difference of 0.9. From the top tick (100,000) down to the next highest tick (10,000) is a

Upload: others

Post on 15-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

1

The Use and Abuse of Logarithmic Axes 

[email protected]

©2009,GraphPadSoftware,Inc.June2009

Mostgraphingprogramscanplotlogarithmicaxes,whicharecommonlyusedandabused.Thisarticleexplainstheprinciplesbehindlogarithmicaxes,soyoucanmakewisechoicesaboutwhentousethemandwhentoavoidthem.

What is a logarithmic axis? 

A logarithmic axis changes the scale of an axis.  

Thetwographsbelowshowthesametwodatasets,plottedondifferentaxes.

Thegraphonthelefthasalinear(ordinary)axis.Thedifferencebetweeneverypairofticksisconsistent(2000inthisexample).

Thegraphontherighthasalogarithmicaxis.Thedifferencebetweeneverypairofticksisnotconsistent.Fromthebottomtick(0.1)tothenexttickisadifferenceof0.9.Fromthetoptick(100,000)downtothenexthighesttick(10,000)isa

Page 2: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

2

differenceof90,000).Whatisconsistentistheratio.Eachaxistickrepresentsavaluetenfoldhigherthantheprevioustick.

Thereddotsplotadatasetwithequallyspacedvalues.EachdotrepresentsavaluewithaYvalue500higherthanthedotbelow.Thedotsareequallyspacedonthegraphontheleft,butfarfromequallyspacedonthegraphontheright.Topreventoverlap,thepointsarejitteredtotherightandleftsotheydon'toverlap.Thehorizontalpositionofthereddotshasnoothermeaning.

ThebluedotsrepresentadatasetwhereeachvaluerepresentsaYvalue1.5timeshigherthantheonebelow.Onthegraphontheleft,thelowervaluesarealmostsuperimposed,makingitveryhardtoseethedistributionofvalues(evenwithhorizontaljittering).Onthegraphontherightwithalogarithmicaxis,thepointsappearequallyspaced.

Interpolating between log ticks 

Whatvalueishalfwaybetweenthetickfor10andtheonefor100?Yourfirstguessmightbetheaverageofthosetwovalues,55.Butthatiswrong.Valuesarenotequallyspacedonalogarithmicaxis.Thelogarithmof10is1.0,andthelogarithmof100is2.0,sothelogarithmofthemidpointis1.5.Whatvaluehasalogarithmof1.5?Theansweris101.5,whichis31.62.Sothevaluehalfwaybetween10and100onalogarithmicaxisis31.62.Similarly,thevaluehalfwaybetween100and1000onalogarithmicaxisis316.2.

Why “logarithmic”?  

Intheexampleabove,theticksat1,10,100,1000areequallyspacedonthegraph.Thelogarithmsof1,10,100and1000are0,1,2,3,whichareequallyspacedvalues.Sincevaluesthatareequallyspacedonthegraphhavelogarithmsthatareequallyspacednumerically,thiskindofaxisiscalleda“logarithmicaxis”.

Lingo 

Thetermsemilogisusedtorefertoagraphwhereoneaxisislogarithmicandtheotherisn’t.Whenbothaxesarelogarithmic,thegraphiscalledalog­log plot.

Other Bases 

Allthelogarithmsshownabovearecalledbase10logarithms,becausethecomputationstake10tosomepower.Thesearealsocalledcommonlogarithms.

Mathematiciansprefernaturallogarithms,usingbasee(2.7183...).Buttheydon’tseemverynaturaltoscientists,andarerarelyusedasanaxisscale.

Abase2logarithmisthenumberofdoublingsittakestoreachavalue,andthisiswidelyusedbycellbiologistsandimmunologists.Ifyoustartwith1anddoubleitfourtimes(2,4,8,and16),theresultis16,sothelogbase2of16is4.

Page 3: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

3

GraphPadPrismcanplotlog2axes.ChoosefromtheupperleftcorneroftheFormatAxisdialog.

Logarithmic axes cannot contain zero or negative numbers 

The logarithms of negative numbers and zero are simply not defined 

Let’sstartwiththefundamentaldefinitionofalogarithm.If10L=Z,thenListhelogarithm(base10)ofZ.IfLisanegativevalue,thenZisapositivefractionlessthan1.0.IfLiszero,thenZequals1.0.IfLisgreaterthan0,thenZisgreaterthan1.0.NotethattherenovalueofLwillresultinavalueofZthatiszeroornegative.Logarithmsaresimplynotdefinedforzeroornegativenumbers.

Thereforealogarithmicaxiscanonlyplotpositivevalues.Theresimplyisnowaytoputnegativevaluesorzeroonalogarithmicaxis.

A trick to plot zero on a logarithmic axis in Prism 

Ifyoureallywanttoincludezeroonalogarithmicaxis,you’llneedtobeclever.Don’tenter0,insteadenterasasmallnumber.Forexample,ifthesmallestvalueinyourdatais0.01,enterthezerovalueas0.001.ThenusetheFormatAxisdialogtocreateadiscontinuousaxis,andusetheAdditionalticksfeatureofPrismtolabelthatspotontheaxisas0.0.

Page 4: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

4

Logarithmic axes on bar graphs are misleading 

Thewholepointofabargraphisthattherelativeheightofthebarstellsyouabouttherelativevaluesplotted.Inthegraphbelow,onebarisfourtimesastallastheotherandonevalue(800)isfourtimestheother(200).

Page 5: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

5

Sincezerocan’tbeshownonalogaxis,thechoiceofastartingplaceisarbitrary.Accordingly,therelativeheightoftwobarsisnotdirectlyrelatedtotheirrelativevalues.Thegraphsbelowshowthesamedataasthegraphabove,butwiththreedifferentchoicesforwheretheaxisbegins.Thisarbitrarychoiceinfluencestherelativeheightofthetwobars,amplifiedinthegraphontheleftandminimizedinthegraphontheright.

Ifthegoalistocreatepropaganda,abargraphusingalogarithmicaxisisagreattool,asitletsyoueitherexaggeratedifferencesbetweengroupsorminimizethem.Allyouhavetodoiscarefullychoosetherangeofyouraxis.Don’tcreatebargraphsusingalogarithmicaxisifyourgoalistohonestlyshowthedata.

When to use a logarithmic axis 

A logarithmic X axis is useful when the X values are logarithmically spaced 

TheX‐axisusuallyplotstheindependentvariable–thevariableyoucontrol.IfyouchoseXvaluesthatareconstantratios,ratherthanconstantdifferences,thegraphwillbeeasiertoviewonalogarithmicaxis.

Thetwographsbelowshowthesamedata.Xisdose,andYisresponse.Thedoseswerechosensoeachdoseistwicethepreviousdose.Whenplottedwithalinearaxis(left)manyofthevaluesaresuperimposedanditishardtoseewhat’sgoingon.

Page 6: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

6

Withalogarithmicaxis(right),thevaluesareequallyspacedhorizontally,makingthegrapheasiertounderstand.

A logarithmic axis is useful for plotting ratios 

Ratiosareintrinsicallyasymmetrical.Aratioof1.0meansnochange.Alldecreasesareexpressedasratiosbetween0.0and1.0,whileallincreasesareexpressedasratiosgreaterthan1.0(withnoupperlimit).

Onalogscale,incontrast,ratiosaresymmetrical.Aratioof1.0(nochange)ishalfwaybetweenaratioof0.5(halftherisk)andaratioof2.0(twicetherisk).Thus,plottingratiosonalogscale(asshownbelow)makesthemeasiertointerpret.Thegraphbelowplotsoddsratiosfromthreecase‐controlretrospectivestudies,butanyratiocanbenefitfrombeingplottedonalogaxis.

Thegraphabovewascreatedwiththeoutcome(theoddsratio)plottedhorizontally.Sincethesevaluesaresomethingthatwasdetermined(notsomethingsetbytheexperimenter),thehorizontalaxisis,essentially,theY‐axiseventhoughitishorizontal.

A logarithmic axis linearizes compound interest and exponential growth 

Thegraphsbelowplotexponentialgrowth,whichisequivalenttocompoundinterest.Attime=0.0,theYvalueequals100.Foreachincrementof1.0ontheX

Page 7: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

7

axis,thevalueplottedontheYaxisequals1.1timesthepriorvalue.Thisisthepatternofcellgrowth(withplentyofspaceandnutrients),andisalsothepatternbywhichaninvestment(ordebt)growsovertimewithaconstantinterestrate.

Thegraphontherightisidenticaltotheoneontheleft,exceptthattheYaxishasalogarithmicscale.Onthisscale,exponentialgrowthappearsasastraightline.

Exponentialgrowthhasaconstantdoublingtime.Forthisexample,theYvalue(cellcount,valueofinvestment…)doublesforeverytimeincrementof7.2657.

An exponential decay curve is linear on a logarithmic axis, but only when it decays to zero 

Thegraphsbelowshowexponentialdecaydowntoabaselineofzero.Thiscouldrepresentradioactivedecay,drugmetabolism,ordissociationofadrugfromareceptor.

Thehalf‐lifeisconsistent.Forthisexample,thehalf‐lifeis3.5minutes.Thatmeansthatattime=3.5minutes,thesignalishalfwhatitwasattimezero.Attime=7.0minutes,thesignalhascutinhalfagain,to25%oftheoriginal.Bytime=10.5minutes,ithasdecayedagaintohalfwhatitwasattime=7.5minutes,whichisdownto12.5%oftheoriginalvalue.

Page 8: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

8

Notethatwhenanexponentialdissociationcurveplateausatavalueotherthanzero,itwillnotbelinearonalogarithmicaxis.ThegraphontherightbelowhasalogarithmicYaxis,buttheexponentialdecay(greencurve)isnotastraightline.

Lognormal distributions  

Plotting lognormal distributions on a logarithmic axis 

Thetwographsbelowplotthesame50values.Thegraphonthelefthasalinear(ordinary)Yaxis,whilethegraphontherighthasalogarithmicscale.

Thedataaresampledfromalognormaldistribution,whichisveryasymmetrical.

Page 9: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

9

Whenshownonalinearscale(graphontheleft),itisimpossibletoreallygetasenseofthedistribution,sinceabouthalfofthevaluesareplottedinpileatthebottomofthegraph.Anotherproblemisthatifyousawonlythegraphontheleft,youmightthinkthehighestfourvaluesareoutliers,sincetheyseemtobesofarfromtheothers.

Whenplottedwithalogarithmicaxis,thedistributionappearssymmetrical,thehighestpointsdon’tseemoutofplace,andyoucanseeallthepoints.

Thesedatacomefromalognormaldistribution.ThatmeansthatthelogarithmsofvaluesfollowaGaussiandistribution.Plottingsuchvaluesonalogarithmicplotmakesthedistributionmoresymmetricalandeasiertounderstand.

The mean and geometric mean  

Thegraphsbelowshowthesamedata,andalsoshowthemeanandgeometricmean.Thegeometricmeaniscomputedbyfirsttransformingallthevaluestologarithms,findingthemeanofthoselogarithms,andthenreversetransformingthatmeanbacktotheoriginalunits.

Withanasymmetricaldistribution,themeanandgeometricmeancanbequitedifferentasshownhere.Whenplottedonalogscale(right),themeanisnotnearthemiddleofthedata.Thatisbecausethepointsabovethemeanhavemuchlargervaluessobringupthemeanvalue.Onalogarithmicaxis,thegeometricmeanisnearthemiddleofthedistribution.

Thisgraphshowsthattheconceptofanaverageormeanissomewhatambiguouswhendataareplottedonalogarithmicaxis.Doyoumeanthemeanoftheactualvalues,orthemeanofthelogarithms(thegeometricmean)?Becauseofthis

Page 10: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

10

ambiguity,considershowingthemedianinstead.Forthesedata,themeanis1541.3,thegeometricmeanis141.2,andthemedianis116.3

Displaying variability on a lognormal distributions 

Intheexampleabove,thestandarddeviation(SD)is4930.TherangethatcoversameanplusorminusoneSD,therefore,extendsfrom1541–4930to1541+4930,whichisfrom‐3389to6741.Thisrangecannotbeplottedonalogarithmicaxis,becausesuchanaxiscannotincludenegativevalues

Onealternativeistocomputeageometric standard deviation,butthesearenotoftenused(muchlessthangeometricmeans)andaretrickytounderstand.

Fordisplaypurposes,ifyouarenotgoingtographeveryindividualvalueasonthegraphsabove,abox‐and‐whiskersplotasshownbelowdoesagreatjobofshowingvariation.Theboxextendsfromthe25thto75thpercentiles,withalineatthemedian(50thpercentile).Thewhiskers,onthisgraph,godowntothesmallestvalueanduptothelargestvalue(alternativedefinitionsareoftenused).Again,thegraphiseasytounderstandwhenalogarithmicaxisisused(right)butisnotveryhelpfulwithalinearaxis.

Page 11: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

11

  

Distinguish using a logarithmic axis from plotting logarithms 

Regression fits the data, not the graph 

Becarefulwhenyoufitacurvetodatawithalogarithmicaxis.Whenyoufitacurvewithnonlinearregression(oralinewithlinearregression),youfitamodel(equation)thatdefinesYasafunctionofX.Choosingtostretcheitheraxistoalogarithmicscaledoesnotchangeanyvalues.

Thetwographsbelowplotthesamedata.Thecurveintheleftgraphwascreatedbyusingnonlinearregressiontofitanexponentialdecaycurve.Thatcurveisalsoshownonthegraphontheright.Withalogarithmicaxis,anexponentialcurvedecayingtozerolooksstraight.

 

Sincethegraphontherightlookslikeastraightline,youmightbetemptedtofitthedatawithlinearregression,ratherthanfittinganexponentialdecaymodelusingnonlinearregression.Thegraphsbelowshowswhathappenswhenyoufitlinearregressiontothosedata.Onalinearaxis(left),thelinearregressionlineindeedlookslikealine.Onalogarithmicaxisincontrast(right),thelinearregressionlineappearscurved.Linearregression(andnonlinearregression)fitthedata,notthegraph.NotethatfourpointshavenegativeYvalues,andthesearesimplyomittedfromthegraphontheright.

Page 12: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

12

 

Use antilog or powers‐of‐ten numbering when plotting values that are logs 

Prism’sbuilt‐indose‐responseequationsallassumethattheXvaluesarelogarithmsofdosesorconcentrations.EnteringtheXvaluesasconcentrationsordoses,andthenstretchingtheaxistoalogarithmicscaleisnotthesameatall.ThatapproachdoesnotchangetheXvalues.

ImaginethattheXvaluesrangefrom1to10,000,andyouwanttofitadose‐responsecurveusingPrism’sbuilt‐inequations.Don’tusealogarithmicaxis.Instead,transformthevaluestologarithms(eitherbeforeenteringthedata,orusingPrism’sTransformanalysis),andplotthese(whicharelogarithms)onalinearaxis.AftertransformingtheXvalueswillrangefrom0to5,andtheXaxiswilllooklikethetopexamplebelow.

Prismletsyouformattheaxistoshowtheoriginalvalues(doses)ratherthanthetransformedvalues(logarithmsofdoses).Thethreeaxesaboveallhavethesame

Page 13: Uses and abuses of logarithmic axes - Amazon S3 · Logarithmic axes cannot contain zero or negative numbers The logarithms of negative numbers and zero are simply not defined Let’s

13

range(0to5).Thefirstaxishasdecimalnumbering,thesecondaxishasantilognumbering,andthethirdaxisusespowers‐of‐tennumbering.ThescreenshotshowshowtoselecttheseontheFormatAxisdialog.

Notethatthebottomtwoaxeshavenotbeenstretchedtoalogarithmscale.Onlythenumbershavebeenwritteninalternativeformats.Eventhoughthetopoftheaxisislabeled10,000or105,thecorrespondingvalueonthegraphactuallyisY=5.AvalueofY=10,000wouldbewayoffscale,unlessyoutransformeditfirst.