Change colour & line width of an Annotation in JFreeChart


I am adding an annotation to my plot, but I can't work out how to change the colour or line width (stroke) of this. I've read through the documentation as best as I can but I'm out of ideas. Can anyone help?

Shape shape = new Ellipse2D.Double(circleXValue - radius, circleYValue - radius, radius + radius, radius + radius); XYShapeAnnotation annotation = new XYShapeAnnotation(shape); // ?? plot.addAnnotation(annotation);


You're using this <a href="http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/annotations/XYShapeAnnotation.html#XYShapeAnnotation%28java.awt.Shape%29" rel="nofollow">constructor</a>:

public XYShapeAnnotation(java.awt.Shape shape)

You may want to use one of <a href="http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/annotations/XYShapeAnnotation.html#XYShapeAnnotation%28java.awt.Shape,%20java.awt.Stroke,%20java.awt.Paint%29" rel="nofollow">these constructors</a> that specify additional parameters:

public XYShapeAnnotation( java.awt.Shape shape, java.awt.Stroke stroke, java.awt.Paint outlinePaint) public XYShapeAnnotation( java.awt.Shape shape, java.awt.Stroke stroke, java.awt.Paint outlinePaint, java.awt.Paint fillPaint)


You can find related examples using <a href="http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/annotations/XYShapeAnnotation.html#XYShapeAnnotation%28java.awt.Shape,%20java.awt.Stroke,%20java.awt.Paint%29" rel="nofollow">XYShapeAnnotation</a> <a href="https://stackoverflow.com/a/6620017/230513" rel="nofollow">here</a> and <a href="https://stackoverflow.com/a/8056418/230513" rel="nofollow">here</a>.

<img alt="image 1" class="b-lazy" data-src="https://i.stack.imgur.com/DUp7P.png" data-original="https://i.stack.imgur.com/DUp7P.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

<img alt="image 2" class="b-lazy" data-src="https://i.stack.imgur.com/4NzNb.png" data-original="https://i.stack.imgur.com/4NzNb.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


  • In ggplot2, how to add text by group in facet_wrap?
  • Matplotlib: two plots on the same axes with different left right scales
  • Matlab FFT and FFTW
  • R - How can I change date format when I plot an xts & zoo object?
  • Plotting a histogram from cellvalues
  • Get Quantile values from geom_boxplot()
  • Email SAS html output
  • ctree plot decision tree in party package in R , terminal node occurs some weird numbers - issue?
  • Retrieving data points from scipy interpolate/griddata
  • Can I override some attribute of drawable shape?
  • several hexbin plots on one PDF page in R
  • get equation of linear SVM regression line
  • Plot a decision tree with R
  • Matplotlib: Custom colormap with three colors [duplicate]
  • How to deal with SpiderWebPlot in JFreeChart?
  • Recreate Apple Watch fitness tracker ‘progress’ bar - gradient on CAShapeLayer stroke
  • Why should be the function backward be called only on 1 element tensor or with gradients w.r.t to Va
  • Base64 as method of sanitizing user input for Mysql
  • Cythonized function unexpectedly slow
  • How to reshape a 3D numpy array?
  • How to change placeholder text in an autocomplete activity of android google place?
  • Geom_jitter colour based on values
  • How to create a 2D image by rotating 1D vector of numbers around its center element?
  • What and where is mdimport
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Use of this Javascript
  • Linq Objects Group By & Sum
  • Get object from AWS S3 as a stream
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Java applet as stand-alone Windows application?
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Jquery - Jquery Wysiwyg return html as a string
  • How to format a variable of double type
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Buffer size for converting unsigned long to string
  • SQL merge duplicate rows and join values that are different
  • How to get Windows thread pool to call class member function?
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • Reading document lines to the user (python)