首页 文章

在Excel中重新排序图表数据系列

提问于
浏览
38

如何重新排序用于在Excel中创建图表的系列?

例如,我转到图表,右键单击>选择数据 . 在左栏中,我看到系列1,系列2,...,系列n . 说,我想在系列4之后移动系列3,可以从图表视图完成吗?我不想移动工作表中的数据单元格 .

我正在使用Excel 2011(mac os x) .

9 回答

  • 3

    选择一个系列并查看公式栏 . 最后一个参数是该系列的情节顺序 . 您可以像在公式栏中一样编辑此公式 .

    例如,选择系列4,然后将4更改为3 .

  • 39

    右键单击图表上的任何系列 . 在“格式数据系列”对话框中,有一个“系列订单”选项卡,您可以在其中上下移动系列 . 我发现这比摆弄系列公式的最后一个参数容易得多 .

    这是在Windows中的Excel 2003中 . Excel 2011 for Mac中有类似的对话框:

    enter image description here

  • 3

    这些是按钮UP / DOWN

    enter image description here

  • 20

    仅供参考,如果您使用两个y轴,则订单编号只会在该y轴系列中产生差异 . 我相信辅助-y轴默认位于主要的顶部 . 如果您希望主轴上的系列位于顶部,则需要将其设为辅助系列 .

  • 1

    见下文

    使用以下代码,如果您使用的是excel 2007或2010,并且只想重新排序图例 . 确保mChartName与您的图表名称匹配 .

    Sub ReverseOrderLegends()
    
    mChartName = "Chart 1"
    Dim sSeriesCollection As SeriesCollection
    Dim mSeries As Series
    With ActiveSheet
        .ChartObjects(mChartName).Chart.SetElement (msoElementLegendNone)
        .ChartObjects(mChartName).Chart.SetElement (msoElementLegendRight)
        Set sSeriesCollection = .ChartObjects(mChartName).Chart.SeriesCollection
        For Each mSeries In sSeriesCollection
            If mSeries.Values(1) = 0.000000123 Or mSeries.Values(1) = Empty Then
                mSeries.Delete
            End If
        Next mSeries
    
        LegendCount = .ChartObjects(mChartName).Chart.SeriesCollection.Count
        For mLegend = 1 To LegendCount
            .ChartObjects(mChartName).Chart.SeriesCollection.NewSeries
            .ChartObjects(mChartName).Chart.SeriesCollection(LegendCount + mLegend).Name = .ChartObjects(mChartName).Chart.SeriesCollection(LegendCount - mLegend + 1).Name
            .ChartObjects(mChartName).Chart.SeriesCollection(LegendCount + mLegend).Values = "={0.000000123}"
            .ChartObjects(mChartName).Chart.SeriesCollection(LegendCount + mLegend).Format.Fill.ForeColor.RGB = .ChartObjects(mChartName).Chart.SeriesCollection(LegendCount - mLegend + 1).Format.Fill.ForeColor.RGB
        Next mLegend
    
        For mLegend = 1 To LegendCount
            .ChartObjects(mChartName).Chart.Legend.LegendEntries(1).Delete
        Next mLegend
    End With
    End Sub
    
  • 63

    要在Excel for Mac 2011下更改图表中系列的堆叠顺序,请执行以下操作:

    • 选择图表,

    • 选择系列(最简单的功能区>图表布局>当前选择),

    • 单击图表布局>格式选择或菜单>格式>数据系列...,
      弹出菜单上的

    • 格式数据系列单击顺序,然后单击单个系列并单击 Move UpMove Down 按钮以调整主题系列的轴上的堆叠顺序 . 这会更改绘图和图例的顺序,但不能更改Series公式中的订单编号 .

    我在辅助轴上有一个三系列的情节,我想在顶部的系列被卡在底部而无视 Move UpMove Down 按钮 . 它恰好被格式化为标记 . 我插入了一行,并且presto(!),我可以改变它在剧情中的顺序 . 后来我可以删除该行,有时它仍然可以订购,但有时不会 .

  • 2

    若要在Excel 2010中更改系列的顺序:

    • 选择(单击)任何数据系列,然后单击"Chart Tools"组中的"Design"选项卡 .

    • 单击"Data"组中的"Select Data",然后在弹出窗口中突出显示要移动的系列 .

    • 单击标有"Legend Entries"(系列)的左侧框顶部的向上或向下三角形 .

  • 1

    Excel 2010 - 如果您要在 pivot chart 上重新排序系列:

    • 转到您的基础数据透视表

    • 右键单击系列的一个列标签__6633336_星期六' or '星期日' in the example shown below) not the '列标签'文本本身)
      弹出菜单中的

    • ,将鼠标悬停在'Move'上,然后从结果子菜单中选择一个选项以重新定位系列变量 .

    • 您的透视图将相应地更新自己

    enter image description here

  • 3

    此函数获取系列名称,将它们放入一个数组中,对数组进行排序,并根据该数组定义将提供所需输出的绘图顺序 .

    Function Increasing_Legend_Sort(mychart As Chart)
    
    
        Dim Arr()
        ReDim Arr(1 To mychart.FullSeriesCollection.Count)
    
            'Assigning Series names to an array
            For i = LBound(Arr) To UBound(Arr)
            Arr(i) = mychart.FullSeriesCollection(i).Name
            Next i
    
            'Bubble-Sort (Sort the array in increasing order)
            For r1 = LBound(Arr) To UBound(Arr)
                rval = Arr(r1)
                    For r2 = LBound(Arr) To UBound(Arr)
                        If Arr(r2) > rval Then 'Change ">" to "<" to make it decreasing
                            Arr(r1) = Arr(r2)
                            Arr(r2) = rval
                            rval = Arr(r1)
                        End If
                    Next r2
            Next r1
    
        'Defining the PlotOrder
        For i = LBound(Arr) To UBound(Arr)
        mychart.FullSeriesCollection(Arr(i)).PlotOrder = i
        Next i
    
    End Function
    

相关问题