# PlotlyJS: faceted density heatmaps

**URL:** <https://discourse.julialang.org/t/plotlyjs-faceted-density-heatmaps/67313>\
**Category:** General Usage\
**Tags:** plotting, plotlyjs\
**Created:** [August 29, 2021, 10:50pm UTC](https://discourse.julialang.org/t/plotlyjs-faceted-density-heatmaps/67313 "2021-08-29T22:50:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [August 29, 2021, 10:50pm UTC](https://discourse.julialang.org/t/plotlyjs-faceted-density-heatmaps/67313/1 "2021-08-29T22:50:51Z")

</div>

Hi,

I am trying to replicate the code that produces a faceted density heatmap using the “tips” data frame. The code I am trying to replicate is this:

```julia
using PlotlyJS, CSV, DataFrames
df = dataset(DataFrame, "tips")

plot(
    df, x=:total_bill, y=:tip, xbingroyp="x", ybingroup="y", kind="histogram2d",
    facet_row=:sex, facet_col=:smoker
)

```

The plot associated with that code is next:

 ![aa](https://global.discourse-cdn.com/julialang/original/3X/6/f/6f6a60e236021bde641e40383b60a17bcbbc63ca.png)

The data frame, named by me as `dftips`, looks like this (just the first 10 rows out of 244):

```julia
244×8 DataFrame
 Row │ total_bill tip sex smoker day time size Column8
     │ Float64 Float64 String String String String Int64 Missing
─────┼─────────────────────────────────────────────────────────────────────
   1 │ 16.99 1.01 Female No Sun Dinner 2 missing
   2 │ 10.34 1.66 Male No Sun Dinner 3 missing
   3 │ 21.01 3.5 Male No Sun Dinner 3 missing
   4 │ 23.68 3.31 Male No Sun Dinner 2 missing
   5 │ 24.59 3.61 Female No Sun Dinner 4 missing
   6 │ 25.29 4.71 Male No Sun Dinner 4 missing
   7 │ 8.77 2.0 Male No Sun Dinner 2 missing
   8 │ 26.88 3.12 Male No Sun Dinner 4 missing
   9 │ 15.04 1.96 Male No Sun Dinner 2 missing
  10 │ 14.78 3.23 Male No Sun Dinner 2 missing
  

```

My adapted piece of code that does not run is:

```julia
Plot(dftips, x=dftips.total_bill, y=dftips.tip, xbingroyp="x", ybingroup="y", kind="histogram2d",
    facet_row=dftips.sex, facet_col=dftips.smoker)

```

However, I get the error:

```julia
TypeError: in keyword argument facet_row, expected Union{Missing, Symbol}, 
got a value of type PooledArrays.PooledVector{String, UInt32, Vector{UInt32}}

```

I replicated all the other examples using this data frame and PlotlyJS. I have no idea how to overcome this obstacle. Help will be very much appreciated.

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [August 30, 2021, 8:16am UTC](https://discourse.julialang.org/t/plotlyjs-faceted-density-heatmaps/67313/2 "2021-08-30T08:16:28Z")

</div>

If you are displaying the dataframe, df, from the first example that works, you can see that  
“total\_bill” and “tip” are column names. Hence your new example should be:

```julia
Plot(dftips, x= :total_bill, y=:tip, xbingroyp="x", ybingroup="y", kind="histogram2d",
    facet_row=:sex, facet_col=:smoker)

```

because perhaps the underlying low level code will take for `x`, `y`, `facet_row` and `facet_col` the corresponding column names from your passed dataframe, `dftips`.

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [August 30, 2021, 9:10am UTC](https://discourse.julialang.org/t/plotlyjs-faceted-density-heatmaps/67313/3 "2021-08-30T09:10:37Z")

</div>

@empet, thanks. Your code works. Yesterday, I tried your code, and it threw out an error. As far as I can remember, I think it was “total\_bill and tip not defined”. Probably, a stupid typo. Thank you.
