Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
1
The Use and Abuse of Logarithmic Axes
©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
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,thegraphiscalledaloglog plot.
Other Bases
Allthelogarithmsshownabovearecalledbase10logarithms,becausethecomputationstake10tosomepower.Thesearealsocalledcommonlogarithms.
Mathematiciansprefernaturallogarithms,usingbasee(2.7183...).Buttheydon’tseemverynaturaltoscientists,andarerarelyusedasanaxisscale.
Abase2logarithmisthenumberofdoublingsittakestoreachavalue,andthisiswidelyusedbycellbiologistsandimmunologists.Ifyoustartwith1anddoubleitfourtimes(2,4,8,and16),theresultis16,sothelogbase2of16is4.
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.
4
Logarithmic axes on bar graphs are misleading
Thewholepointofabargraphisthattherelativeheightofthebarstellsyouabouttherelativevaluesplotted.Inthegraphbelow,onebarisfourtimesastallastheotherandonevalue(800)isfourtimestheother(200).
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.
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
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.
8
Notethatwhenanexponentialdissociationcurveplateausatavalueotherthanzero,itwillnotbelinearonalogarithmicaxis.ThegraphontherightbelowhasalogarithmicYaxis,buttheexponentialdecay(greencurve)isnotastraightline.
Lognormal distributions
Plotting lognormal distributions on a logarithmic axis
Thetwographsbelowplotthesame50values.Thegraphonthelefthasalinear(ordinary)Yaxis,whilethegraphontherighthasalogarithmicscale.
Thedataaresampledfromalognormaldistribution,whichisveryasymmetrical.
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
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.
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.
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
13
range(0to5).Thefirstaxishasdecimalnumbering,thesecondaxishasantilognumbering,andthethirdaxisusespowers‐of‐tennumbering.ThescreenshotshowshowtoselecttheseontheFormatAxisdialog.
Notethatthebottomtwoaxeshavenotbeenstretchedtoalogarithmscale.Onlythenumbershavebeenwritteninalternativeformats.Eventhoughthetopoftheaxisislabeled10,000or105,thecorrespondingvalueonthegraphactuallyisY=5.AvalueofY=10,000wouldbewayoffscale,unlessyoutransformeditfirst.