資源描述:
《the r book graphics》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、5GraphicsProducinghigh-qualitygraphicsisoneofthemainreasonsfordoingstatisticalcomputing.Theparticularplotfunctionyouneedwilldependonthenumberofvariablesyouwanttoplotandthepatternyouwishtohighlight.Theplottingfunctionsinthischapteraredealtwithunderfourheadings:plotswithtw
2、ovariables;plotsforasinglesample;multivariateplots;specialplotsforparticularpurposes.ChangestothedetailedlookofthegraphsaredealtwithinChapter29.5.1PlotswithtwovariablesWithtwovariables(typicallytheresponsevariableontheyaxisandtheexplanatoryvariableonthexaxis),thekindof
3、plotyoushouldproducedependsuponthenatureofyourexplanatoryvariable.Whentheexplanatoryvariableisacontinuousvariable,suchaslengthorweightoraltitude,thentheappropriateplotisascatterplot.Incaseswheretheexplanatoryvariableiscategorical,suchasgenotypeorcolourorgender,thentheappr
4、opriateplotiseitherabox-and-whiskerplot(whenyouwanttoshowthescatterintherawdata)orabarplot(whenyouwanttoemphasizetheeffectsizes).ThemostfrequentlyusedplottingfunctionsfortwovariablesinRarethefollowing:plot(x,y)scatterplotofyagainstx;plot(factor,y)box-and-whiskerplotofya
5、teachfactorlevel;barplot(y)heightsfromavectorofyvalues(onebarperfactorlevel).TheRBook,SecondEdition.MichaelJ.Crawley.?2013JohnWiley&Sons,Ltd.Published2013byJohnWiley&Sons,Ltd.190THERBOOK5.2Plottingwithtwocontinuousexplanatoryvariables:ScatterplotsTheplotfunctiondrawsaxes
6、andaddsascatterplotofpoints.Twoextrafunctions,pointsandlines,addextrapointsorlinestoanexistingplot.Therearetwowaysofspecifyingplot,pointsandlinesandyoushouldchoosewhicheveryouprefer:Cartesianplot(x,y)formulaplot(y~x)Theadvantageoftheformula-basedplotisthattheplotfunctio
7、nandthemodel?tlookandfeelthesame(responsevariable,tilde,explanatoryvariable).IfyouuseCartesianplots(eastings?rst,thennorthings,likethegridreferenceonamap)thentheplothas‘xtheny’whilethemodelhas‘ythenx’.Atitsmostbasic,theplotfunctionneedsonlytwoarguments:?rstthenameoftheexp
8、lanatoryvariable(xinthiscase),andsecondthenameoftheresponsevariable(yinthiscase):plot(x,y).Theda