Excel图形轴自动调整大小 [英] Excel Graph Automatic Resizing of Axis Origin

查看:183
本文介绍了Excel图形轴自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码绘制散点图。有没有一种调整绘图区域大小的方法,使x轴和y轴不总是从零开始,而是低于最低值?目前我所有的数据点都聚集在一个角落里。非常感谢!

I have the following code which plots a scatter plot. Is there an elegant way to resize the plot area such that the x and y axis do not always automatically start from zero, but rather just below the lowest value? At the moment all my data points end up bunched up in one corner. Many thanks!

Set cht = ActiveChart
'GRAPH 1
    Set rng1 = ActiveSheet.Range(Range("AC13").Offset(jump * 50, 0), Range("AG23").Offset(jump * 50, 0))

With ActiveSheet.ChartObjects.Add(Left:=rng1.Left, Width:=rng1.Width, Top:=rng1.Top, Height:=rng1.Height)
 '(Left:=100, Width:=375, Top:=75, Height:=225)
    .Chart.ChartType = xlXYScatterLines
    .Chart.HasLegend = False
    .Chart.Axes(xlCategory).TickLabels.Font.Size = 18
    .Chart.Axes(xlValue).TickLabels.Font.Size = 18
    '.Chart.SetSourceData Source:=Range("U13:O40,T13:N40")
    Set srs = .Chart.SeriesCollection.NewSeries
            srs.XValues = Range(Range("U13").Offset(jump * 50, 0), Range("U13").Offset(jump * 50, 0).End(xlDown))
    srs.Values = Range(Range("T13").Offset(jump * 50, 0), Range("T13").Offset(jump * 50, 0).End(xlDown))

End With


推荐答案

范围数据在 ActiveSheet 的单元 B1:B10 中,那么你可以使用这样的代码来开始90

If your y-range data was in cells B1:B10 of the ActiveSheet then you could use code like this to start the range at 90% of the lowest value (ie just below)

Set cht = ActiveChart
cht.Axes(xlValue).MinimumScale = 0.9 * Application.Min([b1:b10])

这篇关于Excel图形轴自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆