怎么设置excel里画出的曲线图大小一致(格式相同),字体之类的
可以通过宏来实现:先按你的需求调整一张图片,并将此过程录制为一个宏,然后查看宏代码,做适当的修改后应用到其余图表,最终可实现所有图表的格式与第一张图保持统一。
下面以Excel 2010为例进行演示:
1、初始数据及图表样式,显然格式不统一
2、如下图创建宏,在弹出菜单中设置宏名(例如chart_style)
3、在新弹出的Visual Basic窗口中,添加如下代码。可以根据注释,修改为需要的样式。
Sub chart_style()
'设置图表区域的宽度和高度
ActiveChart.ChartArea.Select
Selection.Width = 230
Selection.Height = 160
'设置绘图区域的大小
ActiveChart.PlotArea.Select
Selection.Top = 0
Selection.Left = 10
Selection.Height = 150
Selection.Width = 210
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
' 设置x轴的字体、大小、粗细
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlCategory).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
With Selection.Format.TextFrame2.TextRange.Font
.NameComplexScript = "Times New Roman"
.NameFarEast = "Times New Roman"
.Name = "Times New Roman"
.Bold = msoFalse
.Size = 13
End With
' 设置y轴的字体、大小、粗细
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveChart.Axes(xlValue).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
ActiveChart.Axes(xlValue).AxisTitle.Select
With Selection.Format.TextFrame2.TextRange.Font
.NameComplexScript = "Times New Roman"
.NameFarEast = "Times New Roman"
.Name = "Times New Roman"
.Bold = msoFalse
.Size = 13
End With
End Sub
4、选中一个图表,点击菜单的“宏”,在弹出窗口中,点击执行;同样设置另一幅图。
5、最终实现效果统一如下