# Plot recipe for existing series type and own type

**URL:** <https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902>\
**Category:** Visualization\
**Tags:** plotting, recipe\
**Created:** [May 6, 2019, 9:48am UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902 "2019-05-06T09:48:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [May 6, 2019, 9:48am UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902/1 "2019-05-06T09:48:36Z")

</div>

I am slightly confused how to properly add a plot recipe for a corrplot of an own-defined type.

Suppose that I have defined the following type

```julia
struct MyType
x::DataFrame
end

```

I would now like to have a corrplot for certain columns (and/or rows) similar to:

```julia
a = MyType(some_data)
corrplot(a, column_indices)

```

What kind of plot recipe do I have to use and how will it look like (I have tried several options, more or less successful)?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 6, 2019, 12:38pm UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902/2 "2019-05-06T12:38:31Z")

</div>

That’s because `corrplot` is a user recipe, so you can’t dispatch to it directly as a seriestype. Your solution should be something like

```julia
@recipe f(m::MyType, columns) = RecipesBase.recipetype(:corrplot, m.x[columns])

```

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [June 16, 2020, 2:58pm UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902/3 "2020-06-16T14:58:07Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![jedforrest](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jedforrest/32/37502_2.png) [@jedforrest](https://discourse.julialang.org/u/jedforrest)\
**Post date:** [February 7, 2022, 7:32am UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902/4 "2022-02-07T07:32:46Z")

</div>

I have a very similar problem to this, except it is for graphplot instead.

When I try:

```julia
using RecipesBase, GraphRecipes

struct MyGraph end

@recipe function f(g::MyGraph)
    curves := false
    RecipesBase.recipetype(:graphplot, g)
end

```

I get:

```julia
ERROR: LoadError: No type recipe defined for type graphplot. You may need to load StatsPlots

```

graphplot comes from the GraphRecipes package, not StatsPlots, so I’m not sure how to respond to this error message.

What do I need to include or change so that I can do something like `graphplot(mygraph)`?

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [February 8, 2022, 6:33pm UTC](https://discourse.julialang.org/t/plot-recipe-for-existing-series-type-and-own-type/23902/5 "2022-02-08T18:33:26Z")

</div>

The `recipetype` function for `graphplot` is not defined. Either you add it yourself using `RecipesBase.recipetype(::Val{:graphplot}, args...) = GraphRecipes.GraphPlot(args)`  
or you directly call the `graphplot` object in your recipe:

```julia
using RecipesBase,GraphRecipes
struct MyGraph end
@recipe function f(g::MyGraph)
   GraphRecipes.GraphPlot([rand(5,5)])
end
using Plots
g = MyGraph()
plot(g)

```
