Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing scatter plot data #393

Open
mametz opened this issue Jun 13, 2018 · 1 comment
Open

Accessing scatter plot data #393

mametz opened this issue Jun 13, 2018 · 1 comment

Comments

@mametz
Copy link

mametz commented Jun 13, 2018

Hi, thanks for the great library!

How would I access the X-values of a scatter plot?
I figured out how to access the Y-values and categories in Barcharts, but I did not come along a method on how to access the X-Values in scatter plots.

           for x in shape.chart.plots:
              for y in x.categories:
                data_xy[1].append(y)

            for ser in shape.chart.series:
                for x in ser.values:
                    data_xy[0].append(x)
@scanny
Copy link
Owner

scanny commented Jun 15, 2018

Something like this might work:

from pptx.chart.series import XySeries  # ---not strictly required
xy_series = chart.series[0]  # ---or however you obtain ref to an XySeries object
assert isinstance(xy_series, XySeries)  # ---not strictly required, just so you know what you've got
xVal = xy_series._element.xVal
for idx in range xVal.ptCount_val):
    print xVal.pt_v(idx)

Compare the code for XySeries.values here and abouts:
https://github.com/scanny/python-pptx/blob/master/pptx/chart/series.py#L172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants