Skip to content

howto background image

Erich Seifert edited this page Mar 14, 2016 · 1 revision

How can I add a background image to my plot?

To add a image to the background of the plot area use the following code:

try {
    String bgImageUrl = "https://eseifert.github.io/logos/GRAL.png";
    BufferedImage bgImage = ImageIO.read(new URL(bgImageUrl));
    TexturePaint background = new TexturePaint(bgImage, new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0));
    plot.getPlotArea().setBackground(background);
} catch (IOException e) {
    ...
}

Clone this wiki locally