# How to customize individual subject fit plots in Pumas

**URL:** <https://discourse.pumas.ai/t/how-to-customize-individual-subject-fit-plots-in-pumas/887>\
**Category:** How-to\
**Created:** [June 13, 2023, 5:04am UTC](https://discourse.pumas.ai/t/how-to-customize-individual-subject-fit-plots-in-pumas/887 "2023-06-13T05:04:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawangpt700](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pawangpt700/32/387_2.png) [@pawangpt700](https://discourse.pumas.ai/u/pawangpt700)\
**Post date:** [June 13, 2023, 5:04am UTC](https://discourse.pumas.ai/t/how-to-customize-individual-subject-fit-plots-in-pumas/887/1 "2023-06-13T05:04:23Z")

</div>

Hello,

I was wondering if there is a way to customize individual subject fit plots in Pumas.

As an example, for a crossover study, I need pk fit plots for each subject stratified by period as below

![image](https://canada1.discourse-cdn.com/flex030/uploads/pumas/original/1X/03a4797db4acd5bdd855082d2ff01274e01f0bf2.png)

and also I need the dose and period in the legend.

---

<div class="post-metadata">

**Author:** ![storopoli](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/storopoli/32/190_2.png) [@storopoli](https://discourse.pumas.ai/u/storopoli)\
**Post date:** [June 14, 2023, 2:12pm UTC](https://discourse.pumas.ai/t/how-to-customize-individual-subject-fit-plots-in-pumas/887/2 "2023-06-14T14:12:32Z")

</div>

`subject_fits` from Pumas currently does not support stratifications.  
You would need to customize a plot from the result of an `inspect` call (to get the pred/ipred).

Here’s a minimal working example:

```julia
using Pumas
using PharmaDatasets
using CairoMakie
using AlgebraOfGraphics

pop = read_pumas(dataset("iv_sd_3"); covariates=[:dosegrp])

model = @model begin
    @param begin
        tvcl ∈ RealDomain(; lower=0)
        tvvc ∈ RealDomain(; lower=0)
        σ ∈ RealDomain(; lower=0)
    end
    @pre begin
        CL = tvcl
        Vc = tvvc
    end
    @dynamics begin
        Central' = -CL/Vc*Central
    end
    @derived begin
        cp = @. 1000 * Central / Vc # Change of units
        dv ~ @. Normal(cp, abs(cp) * σ)
    end
end

inspect_df = DataFrame(inspect(
    fit(
        model, pop, init_params(model), NaivePooled()
    )
))

plt = data(dropmissing(inspect_df, :dv_ipred)) *
    mapping(
        :time,
        :dv_ipred;
        color=:dosegrp => nonnumeric,
    ) *
    visual(Lines)

draw(plt)

```

Which generates:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/pumas/original/1X/cfc53728c682ec9b32a27d4d0c5e46f06a1658f5.png)

I highly recommend the Data Visualizations tutorials at tutorials.pumas.ai.
