<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy bar chart rotation not working in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1283758#M68527</link>
    <description>&lt;P&gt;Thank you for the reply,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/485810"&gt;@ChristopherAllen&lt;/a&gt;.&amp;nbsp; I look forward to exploring "arcpy.charts", not to be confused with the old-fashioned "arcpy.Chart" class.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Apr 2023 10:42:56 GMT</pubDate>
    <dc:creator>LauraTateosian</dc:creator>
    <dc:date>2023-04-28T10:42:56Z</dc:date>
    <item>
      <title>arcpy bar chart rotation not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131667#M49693</link>
      <description>&lt;P&gt;Based on my understanding, setting the rotated property of a bar chart to True should draw the bars horizontally.&amp;nbsp; &amp;nbsp;Adding c.rotated to the code below still generates verticle bars.&amp;nbsp; Is this functionality broken?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;c = arcpy.Chart("chart1")
c.title = "Land cover in Gettysburg Battlefield"
c.rotated = True
c.type = "bar"
c.xAxis.field = "COVER"
c.bar.aggregation = "COUNT"

c.xAxis.title = "Land cover"
c.yAxis.title = "Number of polygons"

prj = arcpy.mp.ArcGISProject("CURRENT")
mxd = prj.listMaps()[0]
thelayer = mxd.listLayers()[0]
c.dataSource = thelayer
c&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Here's the chart" style="width: 531px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31013iE80FC04CCA6678B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-01-07_12-54-17.png" alt="Here's the chart" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Here's the chart&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;From &lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/charts/bar.htm" target="_blank" rel="noopener"&gt;this documentation page&lt;/A&gt;, here's the description of the bar chart &lt;EM&gt;rotated&lt;/EM&gt; property:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;Indicates whether the chart is viewed vertically or horizontally. The chart displays vertically by default.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;True&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;rotates the chart horizontally.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;displays the chart vertically.&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131667#M49693</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2022-01-07T18:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy bar chart rotation not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131681#M49701</link>
      <description>&lt;P&gt;from the code example way at the bottom&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;chart.updateChart()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think if you don't create the chart using argument name (eg rotated=True) when creating it, it uses the default.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The other thought which I hope isn't true, is that it changes the page orientation.... but that would be just plain bad&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131681#M49701</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-01-07T18:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy bar chart rotation not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131689#M49702</link>
      <description>&lt;P&gt;Okay, thanks. Your suggestions gave me some ideas that eventually led me to the solution.&amp;nbsp; My first 2 tries were failures:&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;&amp;nbsp;c = arcpy.Chart("chart1", rotated = True) gave me the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;TypeError                                 Traceback (most recent call last)
In  [25]:
Line 1:     c = arcpy.Chart("chart1", rotated=True)
TypeError: __init__() got an unexpected keyword argument 'rotated'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(BTW, I also tested using rotate = True in case it's a typo in the documentation)&amp;nbsp;&amp;nbsp;But I guess the keyword arguments only work if you are calling it on the Bar chart object.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) I added a c.updateChart() before the last line and got this exception:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Exception                                 Traceback (most recent call last)
In  [28]:
Line 15:    c.updateChart()

File c:\program files\arcgis\pro\Resources\arcpy\arcpy\_chart.py, in updateChart:
Line 522:   return convertArcObjectToPythonObject(self._arc_object.updateChart(*gp_fixargs((), True)))

Exception: Invalid layer or table.
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp; Here's what worked:&amp;nbsp; After setting type to bar, set the bar chart object to rotated&amp;nbsp; (c.bar.rotated = True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;c = arcpy.Chart("chart1")
c.title = "Land cover in Gettysburg Battlefield" 
c.type = "bar"
c.bar.rotated = True  # Rotated is a bar property, not a chart property.
c.xAxis.field = "COVER"
c.bar.aggregation = "COUNT"
c.xAxis.title = "Land cover"
c.yAxis.title = "Number of polygons"
prj = arcpy.mp.ArcGISProject("CURRENT")
mxd = prj.listMaps()[0]
thelayer = mxd.listLayers()[0]
c.dataSource = thelayer
c&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bottom line?&amp;nbsp; &amp;nbsp;&lt;EM&gt;rotated&lt;/EM&gt; is a bar property, not a chart property (since not all chart types can be rotated).&amp;nbsp; &amp;nbsp;This was confusing since all the other properties I used are both chart and bar properties.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;By the way, I tried code similar to that example at the bottom of the page and got an error.&amp;nbsp; This code generated the error you see below it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;bar = arcpy.chart.Bar(x="COVER", 
                       aggregation="COUNT", 
                       title="Land cover in Gettysburg Battlefield",
                       xTitle = "Land cover",
                       yTitle = "Number of polygons",
                       rotated=True,
                       dataSource=theLayer)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
In  [42]:
Line 6:     bar = arcpy.chart.Bar(x="COVER", 

AttributeError: module 'arcpy' has no attribute 'chart'
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 19:09:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1131689#M49702</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2022-01-07T19:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy bar chart rotation not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1132579#M49830</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/134677"&gt;@LauraTateosian&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the great question! You are correct, since the `rotated` property is specific to bar charts, you set this property similar to how you set the `aggregation` property (with `c.bar.rotated` rather than `c.rotated`).&lt;/P&gt;&lt;P&gt;I also wanted to address the error you are seeing in the final code example from your follow-up post. In your initial post, you used the original arcpy charting interface to create the chart (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/chart.htm" target="_blank" rel="noopener"&gt;documentation page&lt;/A&gt;). However, in the final code example of your follow-up post, you used the newer `arcpy.charts` module that was introduced in version 2.8 of Pro (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/charts/what-is-the-charts-module.htm" target="_blank" rel="noopener"&gt;documentation page&lt;/A&gt;). The module is called `arcpy.charts` rather than `arcpy.chart`, so it appears that this might have caused the error you are seeing. For instance, here's a bar chart created with the `arcpy.charts` module:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyr = arcpy.mp.ArcGISProject("current").listMaps()[0].listLayers()[0]
# Note: using `arcpy.charts.Bar`
c = arcpy.charts.Bar(x="status", aggregation="COUNT", rotated=True,
                     title="Street Tree Status", xTitle="Tree Status",
                     yTitle="Number of Trees", dataSource=lyr)
c&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="callen_esri_0-1641930413680.png" style="width: 320px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31223iC408279F59109BA4/image-dimensions/320x242?v=v2" width="320" height="242" role="button" title="callen_esri_0-1641930413680.png" alt="callen_esri_0-1641930413680.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For more information on the newer `arcpy.charts` module and how it differs from the original arcpy charting interface, please see the following blog post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-pro/analytics/making-charts-more-class-y-with-the-new-arcpy-charts-module/" target="_blank"&gt;https://www.esri.com/arcgis-blog/products/arcgis-pro/analytics/making-charts-more-class-y-with-the-new-arcpy-charts-module/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Take care,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 19:59:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1132579#M49830</guid>
      <dc:creator>ChristopherAllen</dc:creator>
      <dc:date>2022-01-11T19:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy bar chart rotation not working</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1283758#M68527</link>
      <description>&lt;P&gt;Thank you for the reply,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/485810"&gt;@ChristopherAllen&lt;/a&gt;.&amp;nbsp; I look forward to exploring "arcpy.charts", not to be confused with the old-fashioned "arcpy.Chart" class.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 10:42:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-bar-chart-rotation-not-working/m-p/1283758#M68527</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2023-04-28T10:42:56Z</dc:date>
    </item>
  </channel>
</rss>

