|
|
Question : forcing excel graph size
|
|
Is there a way of forcing excel to size a graph so that the x and y axes are of equal length? I need to create numerous scatter plots, which when printed, have a square plot area (for ROC curves). I have tried changing the plot area manually so that it looks correct on the screen, but when it prints, excel ignores this and prints to fit the page. Thanks Barbara-Ann
|
Answer : forcing excel graph size
|
|
Barbara-Ann, See if this is closer to what you want to do. I set the x and y axes to go from 0 to 1, with 0.1 major units. I then set the chart size to 300x275 pixels, with the plot area 250x250. You'll need to play around with these four numbers to get it to look like you want.
Sub MakeAllChartsSquare() Dim myChartObject As ChartObject Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.ChartObjects.Count > 0 Then For Each myChartObject In ws.ChartObjects MakeChartSquare myChartObject.Chart Next End If Next End Sub
Sub MakeChartSquare(myChart As Chart) With myChart ' get plot size With .Parent 'Height and width of the box enclosing the chart in pixels .Height = 275 .Width = 300 End With With .PlotArea 'Height and width of chart in pixels .Height = 250 .Width = 250 End With ' Get axis scale parameters and lock scales With .Axes(xlValue) .MaximumScale = 1 .MinimumScale = 0 .MajorUnit = 0.1 .MaximumScaleIsAuto = False .MinimumScaleIsAuto = False .MajorUnitIsAuto = False End With With .Axes(xlCategory) .MaximumScale = 1 .MinimumScale = 0 .MajorUnit = 0.1 .MaximumScaleIsAuto = False .MinimumScaleIsAuto = False .MajorUnitIsAuto = False End With End With
End Sub
Brad
|
|
|
|
|