# NIBR data analysis

**URL:** <https://discourse.pumas.ai/t/nibr-data-analysis/630>\
**Category:** How-to\
**Created:** [February 22, 2022, 11:56pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630 "2022-02-22T23:56:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 22, 2022, 11:56pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/1 "2022-02-22T23:56:46Z")

</div>

Hello. I am going through a project systematically to learn Pumas.  
This is the dataprep step. As part of the dataprep step, I would like to run the read\_nca, read\_pumas to ensure data is properly formatted. read\_nca runs fine. However I encounter an error with read\_pumas. I am unable to decipher the following error. I am providing the code and the data link below. Any help is greatly appreciated.  
Bob

```auto
###############################
"ERROR: LoadError: MethodError: no method matching preprocess_data(::DataFrame, ::Symbol, ::Symbol, ::Nothing, ::Symbol, ::Bool)
Closest candidates are:
  preprocess_data(::AbstractDataFrame, ::Vector{Symbol}, ::Symbol, ::Union{Nothing, Symbol}, ::Union{Nothing, Symbol}, ::Bool) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/data_parsing/io.jl:1182
Stacktrace:
 [1] read_pumas(df::DataFrame; observations::Symbol, covariates::Vector{Symbol}, id::Symbol, time::Symbol, evid::Symbol, amt::Symbol, addl::Symbol, ii::Symbol, cmt::Symbol, rate::Symbol, ss::Symbol, route::Symbol, mdv::Nothing, event_data::Bool, covariates_direction::Symbol, check::Bool, adjust_evid34::Bool)
   @ Pumas /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/data_parsing/io.jl:1131
 [2] top-level scope
   @ ~/data/code/practice/nibr/data/dataprep.jl:57"

```

The code is here:

```auto
using Random
using CSV
using Pumas
using PumasUtilities
using Chain
using CategoricalArrays
using StatsBase
using Bioequivalence.GLM: lm, @formula
using DataFramesMeta

############################
#Data specifications
##Column name	Description
##ID Unique subject id (numeric)
##TIME Time relative to first drug administration
##NOMTIME	Nominal time
##TIMEUNIT	unit of TIME
##AMT Dosing amount (for dosing events) in mg (numeric)
##LIDV Observation on a linear scale (Observation type determined by CMT),
##EVENTU Units (numeric)
##CMT Compartment number (determines observation type) (integer)
##CMT 1 Dosing event
##CMT 2 PK concentration
##NAME description of event
##EVENTU	unit for observation
##CENS censored values (0 = not censored, 1 = censored) (integer)
##EVID event ID (0 = observation, 1 = dosing event) (integer)
##WEIGHTB	baseline bodyweight (kg)
##SEX sex
##TRTACT	Treatment group label (string)
##DOSE randomized dose in mg (numeric)

#Data Source https://opensource.nibr.com/xgx/Data/Single_Ascending_Dose_Dataset2.csv 
#Details https://opensource.nibr.com/xgx/Datasets.html#single_ascending_dose_dataset2 
###########################

pkdata = CSV.File("../code/practice/nibr/data/Single_Ascending_Dose_Dataset2.csv"; header=1, missingstring="NA") |> DataFrame
pkdata[!,:ROUTE] .= "ev"
pkdata[!,:AMT_UG] .= pkdata.AMT .* 1000

pkdata = @chain pkdata begin
                        @select :ID :TIME :NOMTIME :AMT_UG :CMT :EVID :LIDV :ROUTE :WEIGHTB :SEX :DOSE
                        @subset :TIME .>= 0
                      end
###### NCA ########
pop_nca = read_nca(pkdata;
                          observations = :LIDV,
                          id = :ID,
                          time = :TIME,
                          route = :ROUTE,
                          amt = :AMT_UG,
                          covariates = [:WEIGHTB, :SEX, :DOSE]
                    )
###################
pop_nmle = read_pumas(pkdata;
                          observations = :LIDV,
                          id = :ID,
                          time = :TIME,
                          route = :ROUTE,
                          amt = :AMT_UG,
                          cmt = :CMT,
                          evid = :EVID,
                          covariates = [:WEIGHTB, :SEX, :DOSE]
                      )

#############

```

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 23, 2022, 12:54am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/2 "2022-02-23T00:54:01Z")

</div>

> [@bobbrown](#):
>
> pop\_nmle = read\_pumas(pkdata;  
> observations = :LIDV,  
> id = :ID,  
> time = :TIME,  
> route = :ROUTE,  
> amt = :AMT\_UG,  
> cmt = :CMT,  
> evid = :EVID,  
> covariates = [:WEIGHTB, :SEX, :DOSE]  
> )

hi Bob -

We have the following heuristic -

1. in NCA we analyze one dependent variable at a time
2. in poppk we can analyze more than one dependent variable at a time.

As a consequence of this, the `observations = ` in `read_nca` accepts a symbol, e.g. `observations = :LIDV`, wheras in poppk, `read_pumas` access `observations` as vector of dependent variables, even if it is just one dependent variable. So, you should change the `observations` in `read_pumas` to `observations = [:LIDV]`.

The error message presented to the user could be a little more informative, but does provide the necessary message that `read_pumas` does not have _method_ `preprocess_data(::DataFrame, ::Symbol, ::Symbol, ::Nothing, ::Symbol, ::Bool)`, instead it is expecting `Closest candidates are: preprocess_data(::AbstractDataFrame, ::Vector{Symbol}, ::Symbol, ::Union{Nothing, Symbol}` focusing on ` ::Vector{Symbol}` which is expecting a vector of observations.

hope that helps?

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 1:25am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/3 "2022-02-23T01:25:41Z")

</div>

Thank you Dr. @vijay

1. Your suggestion worked.
2. How to recognize that @select expects variables without commas; and observations or covariates arguments expect variables separated by commas?
3. For semi-log plot, how to change the yaxis from scientific notation (10E-1) to decimal (0.1).
4. Is there a way to export the plots as a PDF file? It is easier to review the plots as a separate file.  
Bob

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 23, 2022, 1:48am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/4 "2022-02-23T01:48:52Z")

</div>

1. Great
2. We have a new tutorial series on Data Wrangling being launched this week. In that tutorial series, we will explain the differences.
3. The default is the use of `ln` when you use `log`. you could try using other forms such as `log10`, or `log2`, as stated in the documentation [Axis](https://makie.juliaplots.org/v0.15.2/examples/layoutables/axis/index.html#log_scales_and_other_axis_scales)
4. yes, any plot can be saved as follows  
`save("path to save plot", plotobject)`  
If you are however interested in saving all plots that you are creating in a session, that functionality is coming up.

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 7:20pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/5 "2022-02-23T19:20:32Z")

</div>

I am trying to make an interpretable semi-log plot. The yaxis numbers are in a scientific notation format. How can I change them 0.01, 0.1…? The suggestion to use log2 instead did not help. It only changed the base. Thank you.

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

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 7:38pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/6 "2022-02-23T19:38:36Z")

</div>

save() command as suggested above gives the following error.  
ERROR: LoadError: UndefVarError: save not defined  
Stacktrace:  
[1] top-level scope  
@ ~/data/code/practice/nibr/data/dataprep.jl:94

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 23, 2022, 7:47pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/7 "2022-02-23T19:47:27Z")

</div>

Make sure to load

`using CairoMakie`

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 7:55pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/8 "2022-02-23T19:55:39Z")

</div>

## Loading this pkg renders a new error. save(“../code/practice/nibr/data/linear\_pk\_plots”, pk\_plots) #Also tried save(“../code/practice/nibr/data/linear\_pk\_plots.pdf”, pk\_plots)

ERROR: LoadError: No applicable\_savers found for UNKNOWN  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:33  
[2] applicable\_savers  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:11 [inlined]  
[3] save(file::String, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:128  
[4] save(file::String, args::Vector{Figure})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:126  
[5] top-level scope  
@ ~/data/code/practice/nibr/data/dataprep.jl:110  
in expression starting at /home/jrun/data/code/practice/nibr/data/dataprep.jl:110

---

<div class="post-metadata">

**Author:** ![korsbo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/korsbo/32/123_2.png) [@korsbo](https://discourse.pumas.ai/u/korsbo)\
**Post date:** [February 23, 2022, 8:09pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/9 "2022-02-23T20:09:46Z")

</div>

I’m not sure what’s going on with the saving error - `save("…/code/practice/nibr/data/linear_pk_plots.pdf", pk_plots)` looks fine to me.

For the number formatting of your y-axis, I think you should be able to supply `ytickformat` to the `axis` attribute. A small example:

```nohighlight
using CairoMakie
plt = lines(1:10, exp.((1:10) .- 8); axis=(;yscale=log10, ytickformat=x->string.(x)))
save("tmp.pdf", plt)

```

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 9:00pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/10 "2022-02-23T21:00:31Z")

</div>

Thank you. It did something, but the yaxis is still unpresentable.

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

Perhaps one of the younger folks can use the dataset I provided and tweak my code to produce the exact graphs listed in [PK - Single Ascending Dose](https://opensource.nibr.com/xgx/Single_Ascending_Dose_PK.html). OR may be we are all corrupted by ggplot.  
Bob

---

<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:** [February 23, 2022, 10:47pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/11 "2022-02-23T22:47:57Z")

</div>

> [@korsbo](#):
>
> ```auto
> using CairoMakie
> plt = lines(1:10, exp.((1:10) .- 8); axis=(;yscale=log10, ytickformat=x->string.(x)))
> save("tmp.pdf", plt)
> 
> ```

I’ve ran all of your code.

Try this, almost similar to @korsbo:

```julia
using CairoMakie
observations_vs_time(
               pop_nca;
               axis=(;yscale=log10, ytickformat=x -> string.(round.(x; digits=1)))
           )
save("tmp.pdf", plt)

```

You can tweak the `digits=` something if you want more digits.

And there it is:

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

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 11:28pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/12 "2022-02-23T23:28:47Z")

</div>

@storopoli Thank you so much.

1. Your suggestion allowed me to control the number of sig digits for the yaxis. But its not quite what is considered standard PK plot. See below: I am trying to reproduce this exactly (except for individual profiles). The ribbon is grey, the yaxis ticks are every order of magnitude, there are gridlines, font size of panel label (ribbon) is smaller than the axes labels.  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/pumas/original/1X/2c7b99a76a7b08e7294c690d7d0720e506a7178e.jpeg)

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 11:31pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/13 "2022-02-23T23:31:47Z")

</div>

@storopoli save() gives a different error now. I feel very bad @storopoli to keep bugging you all; if there is another resource that I should be reviewing before I shoot off my silly questions, I can save you all some heart burn. What I tried is to add ImageMagic - that did not pan out well either. I received a unresolved error. sorry.

# Errors encountered while save FileIO.File{FileIO.DataFormat{:PDF}, String}(“tmp.pdf”). All errors:

ArgumentError: Package ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1] is required but does not seem to be installed:

- Run `Pkg.instantiate()` to install all recorded dependencies.

# =========================================== ArgumentError: Argument does not support conversion to pdf.

Fatal error:  
ERROR: LoadError: ArgumentError: Package ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1] is required but does not seem to be installed:

- Run `Pkg.instantiate()` to install all recorded dependencies.

Stacktrace:  
[1] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:990  
[2] require(uuidkey::Base.PkgId)  
@ Base ./loading.jl:914  
[3] #34  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:203 [inlined]  
[4] lock(f::FileIO.var"#34#35"{Base.PkgId}, l::ReentrantLock)  
@ Base ./lock.jl:187  
[5] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, file::FileIO.Formatted, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:203  
[6] action  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:197 [inlined]  
[7] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, sym::Symbol, file::String, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185  
[8] action  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185 [inlined]  
[9] save(file::String, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:129  
[10] save(file::String, args::Vector{Figure})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:126  
[11] top-level scope  
@ ~/data/code/practice/nibr/data/dataprep.jl:100  
[12] eval  
@ ./boot.jl:360 [inlined]  
[13] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base ./loading.jl:1094  
[14] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ Base ./essentials.jl:708  
[15] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)  
@ Base ./essentials.jl:706  
[16] inlineeval(m::Module, code::String, code\_line::Int64, code\_column::Int64, file::String; softscope::Bool)  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:204  
[17] (::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:156  
[18] withpath(f::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/repl.jl:177  
[19] (::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:154  
[20] hideprompt(f::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/repl.jl:36  
[21] (::VSCodeServer.var"#56#60"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:122  
[22] with\_logstate(f::Function, logstate::Any)  
@ Base.CoreLogging ./logging.jl:491  
[23] with\_logger  
@ ./logging.jl:603 [inlined]  
[24] (::VSCodeServer.var"#55#59"{VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:194  
[25] #invokelatest#2  
@ ./essentials.jl:708 [inlined]  
[26] invokelatest(::Any)  
@ Base ./essentials.jl:706  
[27] macro expansion  
@ ~/data/.code-server-extensions/julialang.language-julia-1.2.8/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]  
[28] (::VSCodeServer.var"#53#54")()  
@ VSCodeServer ./task.jl:411  
Stacktrace:  
[1] handle\_error(e::ArgumentError, q::Base.PkgId, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/error\_handling.jl:61  
[2] handle\_exceptions(exceptions::Vector{Tuple{Any, Union{Base.PkgId, Module}, Vector{T} where T}}, action::String)  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/error\_handling.jl:56  
[3] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, file::FileIO.Formatted, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:226  
[4] action  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:197 [inlined]  
[5] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, sym::Symbol, file::String, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185  
[6] action  
@ /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185 [inlined]  
[7] save(file::String, args::Vector{Figure}; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:129  
[8] save(file::String, args::Vector{Figure})  
@ FileIO /builds/PumasAI/PumasSystemImages-jl/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:126  
[9] top-level scope  
@ ~/data/code/practice/nibr/data/dataprep.jl:100

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 23, 2022, 11:43pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/14 "2022-02-23T23:43:57Z")

</div>

@bobbrown can you instead try saving as a `png` file?

`save(""…/code/practice/nibr/data/linear_pk_plots.png", pk_plots)`

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [February 23, 2022, 11:46pm UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/15 "2022-02-23T23:46:29Z")

</div>

Did not help. Of course there is a very long new error msg - could not even scroll all the way to the top.  
LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Combined{Makie.poly, Tuple{Vector{Vector{Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Combined{Makie.poly, Tuple{Vector{Vector{Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Combined{Makie.poly, Tuple{Vector{Vector{Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ LineSegments{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{String}}  
├ Lines{Tuple{Vector{Point{2, Float32}}}}  
├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 24, 2022, 12:13am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/16 "2022-02-24T00:13:14Z")

</div>

> [@bobbrown](#):
>
> See below: I am trying to reproduce this exactly (except for individual profiles). The ribbon is grey, the yaxis ticks are every order of magnitude, there are gridlines, font size of panel label (ribbon) is smaller than the axes labels.

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

As you can see we are able to generate the exact plot as you requested, with a lot more customization options.

here is the code that generated the plot you requested based on the exact same dataset that you are trying. Does this come close to what you need?

```julia
ot = observations_vs_time(ncapop, 
                                axis = (xlabel = "Time (hours)", 
                                        ylabel = "CTMX Concentration (μg/mL)",
                                        yscale=log10, ytickformat=x -> string.(round.(x; digits=1)), 
                                        yticks = [0.1, 1, 10],
                                        ygridwidth = 3, 
                                        yminorticksvisible = true,
                                        yminorgridvisible = true,
                                        yminorticks = IntervalsBetween(10),
                                        xminorticksvisible = true,
                                        xminorgridvisible = true,
                                        xminorticks = IntervalsBetween(5),
                                        limits = (nothing, nothing, nothing, 20),
                                        spinewidth = 2),
                                        columns = 4, rows = 3,
                                        facet = ( combinelabels = true,))

```

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 24, 2022, 12:24am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/17 "2022-02-24T00:24:37Z")

</div>

> [@bobbrown](#):
>
> Your suggestion allowed me to control the number of sig digits for the yaxis. But its not quite what is considered standard PK plot. See below: I am trying to reproduce this exactly (except for individual profiles). The ribbon is grey, the yaxis ticks are every order of magnitude, there are gridlines, font size of panel label (ribbon) is smaller than the axes labels.

Sorry, this was the plot you requested to be replicated without the gray overlay of individual profiles @bobbrown

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

here is the code

```julia
sp = summary_observations_vs_time(ncapop, 
                                  color = :black, linewidth = 2, whiskerwidth = 8,
                                  columns = 5, rows = 1,
                                  axis = (xlabel = "Time (hours)", 
                                            ylabel = "Concentration (μg/mL)",
                                            yscale=log10, ytickformat=x -> string.(round.(x; digits=1)), 
                                            yticks = [0.1, 1, 10],
                                            ygridwidth = 3, 
                                            yminorgridcolor = :darkgrey,
                                            yminorticksvisible = true,
                                            yminorgridvisible = true,
                                            yminorticks = IntervalsBetween(10),
                                            xminorticksvisible = true,
                                            xminorgridvisible = true,
                                            xminorticks = IntervalsBetween(5),
                                            limits = (nothing, nothing, nothing, 30),
                                            spinewidth = 2),
                                    facet = ( combinelabels = true,),
                                    figure = (resolution = (1800,600),
                                                        fontsize = 22))

```

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 24, 2022, 12:31am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/18 "2022-02-24T00:31:27Z")

</div>

> [@bobbrown](#):
>
> save() gives a different error now.

here is my code to save a pdf file

```julia
julia> save("./example1.pdf", sp)
CairoScreen{Cairo.CairoSurfaceIOStream{UInt32}} with surface:
Cairo.CairoSurfaceIOStream{UInt32}(Ptr{Nothing} @0x000000000b714490, 1350.0, 450.0, IOContext(IOStream(<file /mnt/myvolume/code/example1.pdf>)))

```

---

<div class="post-metadata">

**Author:** ![benjaminrich](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/benjaminrich/32/156_2.png) [@benjaminrich](https://discourse.pumas.ai/u/benjaminrich)\
**Post date:** [February 24, 2022, 12:37am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/19 "2022-02-24T00:37:38Z")

</div>

Hi @vijay. Thanks for posting that. Very nice!

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/michael/32/818_2.png) [@Michael](https://discourse.pumas.ai/u/Michael)\
**Post date:** [February 24, 2022, 8:21am UTC](https://discourse.pumas.ai/t/nibr-data-analysis/630/20 "2022-02-24T08:21:03Z")

</div>

The original error message contains `save(file::String, args::Vector{Figure})` which indicates that `pk_plots` is a `Vector{Figure}` rather than just a single `Figure` object. Can you try calling `save("filename.pdf", pk_plots[1])` and see whether that saves a plot out?

`ytickformat` can also be set to a “format string” such as `ytickformat = "{:.1f}"` instead of a formatting function, which is sometimes a better option.

[Next page](https://discourse.pumas.ai/t/nibr-data-analysis/630.md?page=2)
