legend scaling
- To: mathgroup at smc.vnet.net
- Subject: [mg54446] legend scaling
- From: Chris Chiasson <chris.chiasson at gmail.com>
- Date: Sun, 20 Feb 2005 00:10:48 -0500 (EST)
- Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Dear MathGroup, Below, I have attached code that is part of one of my homework assignments in my powertrain class. The code contains all input statements up to and including a graph I am working on. I mapped steady state 100% throttle engine power to top gear vehicle speed for different drivetrain configurations. I superimposed the road load power onto the same graph. My concern is with the legend below the graph. If I change the ImageSize->600 argument in the last command, the legend box becomes larger or smaller. How do I make sure that no matter what size I choose for the ImageSize, that the legend always stays nicely wrapped around the legend text? Thank you in advance for your valuable time. EngineTorqueVsEngineSpeedData= Transpose[{# 2\[Pi]/60 (rad)/s&/@{1000,1400,2100,2800,3500,4200,4900,5300, 5700},{61.0,67.6,73.7,78.5,80.9,77.3,76.2,73.3,68.7} kg m^2/s^2/ rad}]; EnginePowerVsEngineSpeedData={#1,#1 #2}&[Sequence@@#]&/@ EngineTorqueVsEngineSpeedData; EnginePowerVsEngineSpeed= MapAt[Evaluate,(Interpolation[{#1 (rad/s)^-1,#2 (kg m^2/s^3)^-1}&[ Sequence@@#]&/@ EnginePowerVsEngineSpeedData][# (rad/s)^-1]kg m^2/s^3&),1]; DrivelineEfficiency[TransmissionReductionRatio_]= 1-(0.06+TransmissionReductionRatio^1.5/100); FinalDriveReductionRatio=(*Interval[{Min[#],Max[#]}&@Rationalize[*){2.95,3.55, 3.73}(*]]*); RollingRadius=(*Interval[*){300/1000 ,310/1000}(*]*) m; RollingResistanceCoefficient=0.015; CoefficientOfDrag=0.335; Area=2 m^2; g=9.81 m/s^2; CurbWeight=g 1350 kg; AirDensity=100000/(286.9*298.15) (kg/m^3); RoadLoadPower= Function[{CarSpeed,GradeAngle}, CarSpeed*(1/2*AirDensity*CarSpeed^2*CoefficientOfDrag*Area+ RollingResistanceCoefficient*CurbWeight*Cos[GradeAngle]+ CurbWeight*Sin[GradeAngle])]; N[DesiredTopSpeed=140 km/h*1000 m/km/(3600 s/h)]; Outer[Times,RollingRadius, 1/rad/TransmissionReductionRatio/FinalDriveReductionRatio]; CarSpeed=Outer[Times,RollingRadius, EngineSpeed/rad/TransmissionReductionRatio/FinalDriveReductionRatio]; CarSpeedAtTopEngineSpeed= CarSpeed/.EngineSpeed->EngineTorqueVsEngineSpeedData[[-1,1]]; TypeBTopSpeedDifference=DesiredTopSpeed-CarSpeedAtTopEngineSpeed; LastGearReductionRatioSolution= Map[Solve[# ==0,TransmissionReductionRatio][[1]]&, TypeBTopSpeedDifference,{2}]; DisplayLastGearReductionRatio= Array[junk,Drop[Dimensions[LastGearReductionRatioSolution],-1]+1]; DisplayLastGearReductionRatio[[ Sequence@@(Range[ 2,#]&/@(Drop[ Dimensions[LastGearReductionRatioSolution],-1]+1))]]= TransmissionReductionRatio/.LastGearReductionRatioSolution; DisplayLastGearReductionRatio[[Range[2,#]&[Length[RollingRadius]+1],1]]= RollingRadius; DisplayLastGearReductionRatio[[1, Range[2,#]&[Length[FinalDriveReductionRatio]+1]]]= FinalDriveReductionRatio; DisplayLastGearReductionRatio[[1,1]]="4th Gear"; TableForm[DisplayLastGearReductionRatio//N, TableHeadings\[Rule]{{"Rolling","","Radius"},{"Final","Drive","Reduction", "Ratio"}}] TopGearNVRatio= EngineTorqueVsEngineSpeedData[[-1,1]]/ CarSpeedAtTopEngineSpeed/.TransmissionReductionRatio\[Rule]1; Needs["Graphics`MultipleListPlot`"] MultipleListPlot[ Append[#,Level[#,{Length@Dimensions@#}-1]&@ ReplaceAll[#,Line[pts_]\[RuleDelayed]List/@pts]&@ First@Block[{$DisplayFunction=Identity}, ReleaseHold[#]]&@ Hold[Plot[ RoadLoadPower[CarSpeed*1000 m/(3600 s),0]/.kg m^2/s^3-> W/.W->1/1000,{CarSpeed,0,160}]]]&@ Level[#,{2}]&@(#/.kg m^2/s^3->W/.W->1/1000/.{m\[Rule]1/1000, s\[Rule]1/3600}/.TransmissionReductionRatio\[Rule]1)&@ Map[ReleaseHold@ ReplacePart[Function[{CarSpeedDummyVariable},Null], Apply[{Hold[CarSpeedDummyVariable/.EngineSpeed\[Rule]#1], DrivelineEfficiency[TransmissionReductionRatio] #2}&, EnginePowerVsEngineSpeedData,{1}],2],CarSpeed,{2}], PlotJoined\[Rule]True, SymbolShape\[Rule]Append[#,None]&@ Take[#,Length[RollingRadius]* Length[FinalDriveReductionRatio]]&@ Apply[PlotSymbol[#1,Filled\[Rule]#2]&,#,{1}]&@Flatten[#,1]&@ Outer[List,{Box,Diamond,Star,Triangle},{True,False}], PlotLegend\[Rule]Append[#,"Road Load"]&@ Level[Outer[ "Rolling Radius: "<>ToString[#1/.m\[Rule]100 cm]<> ", Final Drive Reduction Ratio: "<>ToString[#2]&,RollingRadius, FinalDriveReductionRatio],{2}],ImageSize\[Rule]600, LegendSize\[Rule]{1.6,0.5},LegendPosition\[Rule]{-.75,-1.25}, LegendSpacing\[Rule]-.3,LegendTextSpace\[Rule]Automatic, AxesLabel\[Rule]{"Speed (kph)","Power (kW)"}, PlotLabel->"Top Gear Power Curves and Road Load"] Regards, -- Chris Chiasson Kettering University Mechanical Engineering Graduate Student 1 810 265 3161
- Follow-Ups:
- Re: legend scaling
- From: Chris Chiasson <chris.chiasson@gmail.com>
- Re: legend scaling