IDL> p = plt.pie(sizes, explode=explode, labels=labels, colors=colors, $
> autopct='%1.1f%%', shadow=1, startangle=90)
IDL> print, p
([<matplotlib.patches.Wedge object at 0x0000000017D6F320>, <matplotlib.patches.Wedge object at 0x0000000018200B00>, <matplotlib.patches.Wedge object at 0x000000001820B320>, <matplotlib.patches.Wedge object at 0x0000000018210B00>], [<matplotlib.text.Text object at 0x0000000017D6FFD0>, <matplotlib.text.Text object at 0x00000000182077F0>, <matplotlib.text.Text object at 0x000000001820BFD0>, <matplotlib.text.Text object at 0x00000000182177F0>], [<matplotlib.text.Text object at 0x00000000182005C0>, <matplotlib.text.Text object at 0x0000000018207DA0>, <matplotlib.text.Text object at 0x00000000182105C0>, <matplotlib.text.Text object at 0x0000000018217DA0>])
IDL> print, p[0]
[<matplotlib.patches.Wedge object at 0x0000000017D6F320>, <matplotlib.patches.Wedge object at 0x0000000018200B00>, <matplotlib.patches.Wedge object at 0x000000001820B320>, <matplotlib.patches.Wedge object at 0x0000000018210B00>]
IDL> print, p[1]
[<matplotlib.text.Text object at 0x0000000017D6FFD0>, <matplotlib.text.Text object at 0x00000000182077F0>, <matplotlib.text.Text object at 0x000000001820BFD0>, <matplotlib.text.Text object at 0x00000000182177F0>]
IDL> print, (p[1])[0].get_text()
Frogs
IDL> print, (p[1])[2].get_text()
Dogs
IDL>
On Monday, March 3, 2014 6:22:34 PM UTC-5, Chris Torrence wrote:
> Well, here's another example that might put both me and David out of business. I installed the Anaconda (python 2.7 package), which comes with all of the matplotlib libraries.
>
>
>
> This example is taken directly from the matplotlib gallery page:
>
> http://matplotlib.org/examples/pie_and_polar_charts/pie_demo _features.html
>
>
>
> Create a pie chart from within IDL:
>
>
>
> plt = pyimport("matplotlib.pyplot")
>
> sizes = [15,30,45,10]
>
> labels = ['Frogs', 'Hogs', 'Dogs', 'Logs']
>
> colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
>
> explode = [0, 0.1, 0, 0]
>
> p = plt.pie(sizes, explode=explode, labels=labels, colors=colors, $
>
> autopct='%1.1f%%', shadow=1, startangle=90)
>
> void = plt.axis('equal')
>
> void = plt.show(block=0)
>
> void = plt.savefig('plot.pdf')
>
>
>
> But here's a question for Jason or Ronn: once I've created the "p" object, it says it is a "tuple". Is there any way to get properties back out of the object? I tried the following:
>
> IDL> pb = pyimportbuiltins()
>
> IDL> pb.getattr(p,'colors')
>
> % PYTHONOBJECT::GETATTR: AttributeError: 'tuple' object has no attribute 'colors'
>
>
>
> Cheers,
>
> Chris
>
> ExelisVIS
|