# Plotting in a different process

**URL:** https://discourse.julialang.org/t/plotting-in-a-different-process/131300
**Category:** General Usage
**Tags:** question, distributed
**Created:** [August 1, 2025, 8:17pm UTC](https://discourse.julialang.org/t/plotting-in-a-different-process/131300 "2025-08-01T20:17:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [August 1, 2025, 8:17pm UTC](https://discourse.julialang.org/t/plotting-in-a-different-process/131300/1 "2025-08-01T20:17:17Z")

</div>

I want to start a second Julia process with

```julia-auto
using DistributedNext
addprocs(1)

```

and use a plotting library, like

```julia-auto
@everywhere using ControlPlots

```

(or Plots or whatever you prefer)

How can I now create a plot in the second Julia process?

```julia-auto
 plot(rand(3))

```

would create a plot in the main process. How can I create the same plot in the second process?

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [August 1, 2025, 8:37pm UTC](https://discourse.julialang.org/t/plotting-in-a-different-process/131300/2 "2025-08-01T20:37:19Z")

</div>

Well basically you need to call the plotting function on the other process.  
Have a look at [`Distributed.remotecall`](https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.remotecall-Tuple%7BAny,%20Integer,%20Vararg%7BAny%7D%7D) and [`Distributed.@spawnat`](https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.@spawnat)

So the general process should be:

1. Add the worker with `addprocs`
2. Setup the worker using e.g.

```julia-auto
@spawnat id begin
    # setup code
    using Plots
    include("plotting_stuff.jl")
end

```

1. Later call plotting functions with the data via `remotecall(plottingfunc, id, args)` or use `@spawnat` again like

```julia-auto
@spawnat id begin
    # plotting code
    plottingfunc(data)
end

```

Alternatively you could setup a channel you just put data in. But that seems more complicated and more limited and I don’t really see the benefits.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [August 1, 2025, 8:43pm UTC](https://discourse.julialang.org/t/plotting-in-a-different-process/131300/3 "2025-08-01T20:43:37Z")

</div>

Thank you!

This works:

```julia-auto
@spawnat 1 display(plot(rand(3)))

```
