# How do I make figures?

```{admonition} What will I learn?
- How to send a picture to ImageJ
- How to export the viewer as a PNG
- How to export the viewer as vector graphics
```

By now, we have learned how to conduct a full analysis on our images. But if the analysis is good, we probably will want to share it with others.
Of course, you could share a whole project with your colleagues to show them how it was done, but a pretty figure is usually more enticing than a zip folder!


## Using ImageJ for figure creation

ImageJ has some great figure creation tools.
QuPath's link with ImageJ lets you take advantage of those.

```{admonition} What to do
1. Locate and click on the ImageJ icon in the upper right corner
2. Click {guilabel}`Send snapshot to ImageJ`.
3. Modify and/or save the screenshot in ImageJ.
```

```{note}
If your window is not maximised, the ImageJ icon might be under {guilabel}`>>`, also in the upper right corner
```

```{figure} ../../images/making_figures/imagejscreenshot.png
Sending an image to ImageJ
```


## Copying the viewer as a PNG

A quick and direct way of making a figure based on analysis in QuPath is to copy the contents of the viewer to the clipboard.
This lets you position the field of view just as you like, and allows you to include elements like the scale bar, annotations, detections, or overlays.

```{admonition} What to do
1. Use {menuselection}`Edit --> Copy to clipboard --> Current viewer`
2. Paste your screenshot into your presentation or editing software
```


## Copying the viewer contents as vector graphics

If you want more control over the figures you create, you can export the viewers' contents as vector graphics.
You will then be able to edit each part individually. 

```{admonition} What to do
1. Use {menuselection}`File --> Export snapshot --> Current viewer content (SVG)`
2. Paste into PowerPoint, Inkscape, or your editing software of choice and ungroup the elements.
3. Work with each element separately
```

This is an example of what you can achieve with this method:
```{figure} ../../images/making_figures/example_Pete.png
An example figure create by exporting elements from QuPath
```


```{warning}
Export an image like this can be very demanding, particularly if you have thousands of objects.
It may also be difficult to paste into other software or cause crashes.
```

## Putting everything together

Let's create a neat figure that showcases what we have learned today.
This will also help us go over the materials one last time.

```{admonition} Challenge
1. Open the image `OS-2.ndpi`
2. Draw a rectangular annotation {{ icon_rectangle }} over the area you want to analyse
3. Click on {{ icon_zoom_to_fit}}
4. Export this content and paste into editing software
5. Count and classify the positive cells.  
  Remember how to do that?  
  You can go back to that chapter: [How do I count positive cells?](https://qupath.github.io/workshop-intro/chapters/how_do_i_count_positive_cells.html)
6. Export this view and paste into editing software
7. Create a measurement map of the Nucleus/Cell area ratio.
  You can revisit how to do it here: [How do I view measurements?](https://qupath.github.io/workshop-intro/chapters/how_do_i_view_measurements.html) 
8. Export and paste into editing software.
  This image will be large, so it might be better to use {menuselection}`Edit --> Copy to clipboard --> Current viewer` instead of {menuselection}`File --> Export snapshot --> Current viewer content (SVG)`
9. Create a scatter plot of the Nucleus/Cell area ratio against Nucleus DAB OD mean.
  Modify the display variables until you like the appearance. Right-click and select {menuselection}`Copy to clipboard`, then paste with the other images.
10. Arrange in a pleasing way, ungroup if necessary to change the appearance of the different objects.
```


```{figure} ../../images/making_figures/example_figure.png
An example figure create in PowerPoint
```


Congrats! Now you can share your progress with anyone you want!
