Scale of axis in a chart

AM

Board Regular
Joined
Dec 13, 2006
Messages
99
Hi everyone!

I would like to know if its possible to do a chart that "X" axis and
"Y" axis have the same scale.

I need that the value x=1 in the "X" axis has the same distance to the origin of the chart that the Y=1 in the "Y" axis when I print the chart.

Thanks

AM
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
AM,

The only why I know, besides [possibly] using VBA, is to have your source data set up with the same scale.

Depending on how your source data looks like you might be able to alter the scaling of the the "X" and "Y" axis with a manual setting by double clicking on each axis.

RAM
 
Upvote 0
Re: Scale of axis in a chart Scale 1:1

This works for XY Scatter Graphs.

Sub ScaleOneToOne()
'Select chart, then run this macro.
'Charts will print 1:1, but 1mm doesn't = 1mm!
Dim theChart
Dim PxPerX As Double
Dim PxPerY As Double
Dim pixelsWide As Integer, pixelsHigh As Integer
Dim xscale As Double, yscale As Double
Dim gpxmn As Double, gpxmx As Double, gpymn As Double, gpymx As Double
Dim xNoAxis As Boolean, yNoAxis As Boolean
Dim xMargin As Double, yMargin As Double
Dim i As Integer

Set theChart = ActiveChart

With theChart
.PlotArea.Left = 0'makes sure it's not too big to start
.PlotArea.Top = 0
.ChartArea.AutoScaleFont = False'otherwise Excel rescales fonts
.PlotArea.Width = .ChartArea.Width
.PlotArea.Height = .ChartArea.Height


pixelsWide = .PlotArea.InsideWidth
pixelsHigh = .PlotArea.InsideHeight

xMargin = .PlotArea.Width - pixelsWide
yMargin = .PlotArea.Height - pixelsHigh


With .Axes(xlCategory)
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
gpxmn = .MinimumScale
gpxmx = .MaximumScale
End With
With .Axes(xlValue)
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
gpymn = .MinimumScale
gpymx = .MaximumScale
End With

PxPerX = pixelsWide / (gpxmx - gpxmn)
PxPerY = pixelsHigh / (gpymx - gpymn)
xscale = Application.Min(PxPerX, PxPerY) / PxPerX
yscale = Application.Min(PxPerX, PxPerY) / PxPerY

With .PlotArea
.Width = pixelsWide * xscale + xMargin
.Height = pixelsHigh * yscale + yMargin
End With


'Scale textbox psn
For i = 1 To .Shapes.count
.Shapes(i).Left = .Shapes(i).Left * xscale
.Shapes(i).Top = .Shapes(i).Top * yscale
Next

End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top