# Easy Chart subplot titles

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434>\
**Category:** Ignition\
**Created:** [December 28, 2017, 9:03pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434 "2017-12-28T21:03:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JNelson](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@JNelson](https://forum.inductiveautomation.com/u/JNelson)\
**Post date:** [December 28, 2017, 9:03pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/1 "2017-12-28T21:03:05Z")

</div>

I’m trying to label each of 2 subplots with different titles. The Chart Title property places a title above the top subplot only. I would like to put a different title above the lower subplot, below the upper one.

As a work-around, I tried using a label on top of the Easy Chart (between the subplots with a gap of 50). This is a less than desirable solution, as resizing the window causes re-positioning of the text (yes, I tried anchoring, resizing, and using relative mode all to no avail).

I also scoured the hidden properties of the Easy Chart and was unable to find a property for a subplot title. Is there such a thing? If so, where is it? If not, does anyone have an acceptable solution?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 28, 2017, 9:23pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/2 "2017-12-28T21:23:53Z")

</div>

Example `configureChart()` script:

```auto
	from org.jfree.chart.axis import NumberAxis
	from java.awt import Font
	for index, plot in enumerate(chart.getPlot().getSubplots()):
		labelAxis = NumberAxis("Subplot %s Title" % (index + 1))
		labelAxis.setLabelFont(Font("Tahoma", Font.BOLD, 16))
		labelAxis.setTickLabelsVisible(False)
		labelAxis.setTickMarksVisible(False)
		labelAxis.setAxisLineVisible(False)
		plot.setDomainAxis(1, labelAxis)

```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c356128d600ff036e83d67d702dded96ad66402b.png)

Cribbed pretty heavily from a response from, ironically, the primary developer of JFreechart: [http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=27047](http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=27047)

---

<div class="post-metadata">

**Author:** ![albetro.15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/albetro.15/32/3922_2.png) [@albetro.15](https://forum.inductiveautomation.com/u/albetro.15)\
**Post date:** [January 2, 2018, 5:33pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/3 "2018-01-02T17:33:14Z")

</div>

pretty nice find! it will centrainly come in handy. Thanks !

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 13, 2021, 9:02pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/4 "2021-01-13T21:02:28Z")

</div>

Reviving a zombie, but is there a variable to use to get the “Subplot %s Title” to show the label created for the subplot, rather than a generic “Subplot 1 Title” “Subplot 2 Title” etc? I’ve been trying to understand [https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/NumberAxis.html](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/NumberAxis.html) values, but not making much headway. Is there a way to insert a variable to read each Subplot label in the “for” loop?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 13, 2021, 10:50pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/5 "2021-01-13T22:50:06Z")

</div>

I’m not sure what you mean by ‘subplot label’ - I don’t see a way to configure subplot labels on the easy chart.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 14, 2021, 4:03pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/6 "2021-01-14T16:03:11Z")

</div>

I’m not entirely certain what you mean either.

There is no UI available way to configure a sub plot title on the easy chart. You have to do it through scripting.

@paul-griffith’s script above defines a new axis with a label defined in the constructor, the ‘Subplot %s Title’ was used for simplicity and illustration, the label can be made specific for the application.

By default plot labels are Null.

If you want to retrieve the plot label after creation, you can loop through all of the plots as shown above and use getDomainAxis().getLabel(). There is also a setLabel() that you should be able to use to set the label.

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 14, 2021, 6:05pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/7 "2021-01-14T18:05:18Z")

</div>

![Subplot labels](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06fc2efa30bd0b18ecd5201bf5fcf5701e78225c.jpeg)

See attached screenshot. I’d like to get the labels from the axis list as the title of each subplot chart. Are the subplot labels a property that can be written?

Following @paul-griffith example, how could I write a different title to each subplot that uses the labels created in the easy chart configurator?

Sorry for such unclear questions, I’m new to all of this.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 14, 2021, 7:08pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/8 "2021-01-14T19:08:32Z")

</div>

So, those Labels are for the Range Axis, in this case that is what is traditionally called the Y-Axis.

It is possible to Access those labels, but it is complicated by the fact that there can possibly be more than one Range Axis assigned to a sub plot, and you would need to decide how that is handled.

As an example, you could do something like the following:

```auto
from org.jfree.chart.axis import NumberAxis
from java.awt import Font

for index, plot in enumerate(chart.getPlot().getSubplots()):
    title = ''
    for rangeIndex in range(plot.getRangeAxisCount()):
        title += plot.getRangeAxis(rangeIndex).getLabel() if len(title) == 0 else 'vs ' + plot.getRangeAxis(rangeIndex).getLabel()
    labelAxis = NumberAxis(title)
    labelAxis.setLabelFont(Font("Tahoma", Font.BOLD, 16))
    lableAxis.setTickLabelsVisible(False)
    lableAxis.setTickMarksVisible(False)
    lableAxis.setAxisLineVisible(False)
    plot.setDomainAxis(1, labelAxis)

```

Note: This is untested so might need a few tweaks, but should get you close.

Also, I shamelessly stole the code provided by @paul-griffith 🤣

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 14, 2021, 7:38pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/9 "2021-01-14T19:38:47Z")

</div>

I used the provided example (thank you!) and got it producing no errors, but no labels either. Is [https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html) the right place to be for these commands?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 14, 2021, 9:28pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/10 "2021-01-14T21:28:53Z")

</div>

> [@robb](#):
>
> Is [XYPlot (JFreeChart 1.5.0 API)](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html) the right place to be for these commands?

Its a pretty good place to start. Just have to drill down to find what you're looking for. Don't neglect the inherited methods.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 18, 2021, 2:42pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/11 "2021-01-18T14:42:39Z")

</div>

So I threw together something to give this a try and the code as I have it produced the results I expected, with 1 exception. We need to make sure that there are subplots defined. The only way I know to do this is to check the type of chart.getPlot() . If there are subplots in use then the type will be CombinedDomainXYPlot.

Code now looks like this:

```auto
from org.jfree.chart.axis import NumberAxis
from java.awt import Font
	
if chart.getPlot().getPlotType() == 'Combined_Domain_XYPlot':
	for index, plot in enumerate(chart.getPlot().getSubplots()):
		title = ''
		for rangeIndex in range(plot.getRangeAxisCount()):
			title += plot.getRangeAxis(rangeIndex).getLabel() if len(title) == 0 else ' vs ' + plot.getRangeAxis(rangeIndex).getLabel()
		labelAxis = NumberAxis(title)
		labelAxis.setLabelFont(Font('Tahoma',Font.BOLD, 16))
		labelAxis.setTickLabelsVisible(False)
		labelAxis.setTickMarksVisible(False)
		labelAxis.setAxisLineVisible(False)
		plot.setDomainAxis(1,labelAxis)
else:
	plot = chart.getPlot()
	title = ''
	for rangeIndex in range(plot.getRangeAxisCount()):
		title += plot.getRangeAxis(rangeIndex).getLabel() if len(title) == 0 else ' vs ' + plot.getRangeAxis(rangeIndex).getLabel()
			
	labelAxis = NumberAxis(title)
	labelAxis.setLabelFont(Font('Tahoma',Font.BOLD, 16))
	labelAxis.setTickLabelsVisible(False)
	labelAxis.setTickMarksVisible(False)
	labelAxis.setAxisLineVisible(False)
	plot.setDomainAxis(1,labelAxis)

```

Single Axes assigned to a subplot:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/8/b88c63a7d62f71736904946881b0e5bb0b18e1be.png)

Multiple Axes assigned to main plot:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/14a5d4d32581082b57aedf67c354a61d5d253913.png)

Multiple Axes assigned to a subplot:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37bdad07bd37666950574e7fe2e13456a9a731b8.png)

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 19, 2021, 6:45pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/12 "2021-01-19T18:45:45Z")

</div>

This works excellently! Thanks for the help with this, it should be a feature in easy charts!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 19, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/13 "2021-01-19T19:10:50Z")

</div>

That code can probably be simplified a bit with a technique like this to handle the subplot case:

```auto
plots = getattr(chart.plot, "subplots", [chart.plot])
for index, plot in enumerate(plots):

```

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 19, 2021, 7:22pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/14 "2021-01-19T19:22:38Z")

</div>

You don’t have to specify the CombinedRangeXYPlots to get it’s characteristics?

Also, I am not having much luck finding where @lrose got the “getLabel()” functions (right word?) from, I was hoping to find a reference list of which variables are “gettable”, as it’d be slick to have the title different from the range axis. I am reading through here [https://www.jfree.org/jfreechart/api/javadoc/index.html?org/jfree/chart/plot/CombinedRangeXYPlot.html](https://www.jfree.org/jfreechart/api/javadoc/index.html?org/jfree/chart/plot/CombinedRangeXYPlot.html) but not finding anything readily.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 19, 2021, 7:28pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/15 "2021-01-19T19:28:14Z")

</div>

> [@robb](#):
>
> You don’t have to specify the CombinedRangeXYPlots to get it’s characteristics?

No, because of Python's dynamic typing, you can just ask for whatever property/method you need, and it'll either exist, or throw an error.

> [@robb](#):
>
> Also, I am not having much luck finding where @lrose got the “getLabel()” functions (right word?) from, I was hoping to find a reference list of which variables are “gettable”, as it’d be slick to have the title different from the range axis. I am reading through here [JFreeChart 1.5.0 API](https://www.jfree.org/jfreechart/api/javadoc/index.html?org/jfree/chart/plot/CombinedRangeXYPlot.html) but not finding anything readily.

`getLabel` is defined on JFreeChart's base `Axis` interface - [Axis (JFreeChart 1.5.0 API)](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/Axis.html#getLabel--). In the case of an XYPlot, you know that `getRangeAxis` returns (at least) a `ValueAxis`, which is a direct inheritor of `Axis`, so it has all the same methods: [XYPlot (JFreeChart 1.5.0 API)](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html#getRangeAxis--)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 19, 2021, 8:06pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/16 "2021-01-19T20:06:30Z")

</div>

> [@paul-griffith](#):
>
> That code can probably be simplified a bit with a technique like this to handle the subplot case:
> 
> ```auto
> plots = getattr(chart.plot, "subplots", [chart.plot])
> for index, plot in enumerate(plots):
> 
> ```

Learn something everyday (or at least be reminded of it).

So that makes the working code:

```auto
from org.jfree.chart.axis import NumberAxis
from java.awt import Font

plots = getattr(chart.plot,"subplots",[chart.plot])
for index, plot in enumerate(plots):
    title = ''
    for rangeIndex in range(plot.getRangeAxisCount()):
        title += plot.getRangeAxis(rangeIndex).getLabel() if len(title) == 0 else ' vs ' + plot.getRangeAxis(rangeIndex).getLabel()
    labelAxis = NumberAxis(title)
    labelAxis.setLabelFont(Font('Tahoma',Font.BOLD,16))
    labelAxis.setTickLabelsVisible(False)
    labelAxis.setTickMarksVisible(False)
    labelAxis.setAxisLineVisible(False)
    plot.setDomainAxis(1,labelAxis)

```

> [@robb](#):
>
> I was hoping to find a reference list of which variables are “gettable”, as it’d be slick to have the title different from the range axis.

I only used the Range Axis label because that is what you were looking for.

The title can be anything that you want it to be, there are even ways that you could make it dynamic.

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 19, 2021, 9:42pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/17 "2021-01-19T21:42:12Z")

</div>

> [@lrose](#):
>
> I only used the Range Axis label because that is what you were looking for.
> 
> The title can be anything that you want it to be, there are even ways that you could make it dynamic.

That's why I was trying to find the different variables, to see if I could set the subplot title independent of the range axis label. I see in the easy chart configurator that there's a "Name" and "Label" columns, and the "getLabel()" function returns the contents of the label column, but I don't see anything like this for Name (at the freechart api page).

I really appreciate your patience, this is my first time doing anything in java/python.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 19, 2021, 10:04pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/18 "2021-01-19T22:04:32Z")

</div>

As far as I know the Name column is an Ignition Specific value and isn’t part of the Axis object.

There may be a way to drill into the easy chart and get to that value but I’m not certain of what that would look like.

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [January 19, 2021, 10:33pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/19 "2021-01-19T22:33:24Z")

</div>

Which is unfortunate since the range axis only gets it name from that column, it appears the Name column is just an identifier. You’ve already been a huge help!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 19, 2021, 10:44pm UTC](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434/20 "2021-01-19T22:44:06Z")

</div>

When looking at javadocs, be sure to look at inherited methods, too.

[Next page](https://forum.inductiveautomation.com/t/easy-chart-subplot-titles/16434.md?page=2)
