# Using Unitful with Plots?

**URL:** <https://discourse.julialang.org/t/using-unitful-with-plots/22780>\
**Category:** New to Julia\
**Created:** [April 5, 2019, 4:39am UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780 "2019-04-05T04:39:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [April 5, 2019, 4:39am UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780/1 "2019-04-05T04:39:10Z")

</div>

Hi,

Can I plot Unitful numbers with Plots?

```julia
using Plots
using Unitful
plot([0.0, 1.0, 2.0]u"s", [3.5, 2.5, 1.5]u"V")

```

gives

```julia
DimensionError: Inf and 0.0 s are not dimensionally compatible.

```

Is there a way to make it work without stripping out the units before passing it to Plots?

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 5, 2019, 5:00am UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780/2 "2019-04-05T05:00:26Z")

</div>

there is a package, [UnitfulPlots.jl](https://github.com/ajkeller34/UnitfulPlots.jl), that maybe is a solution, but i can’t make it work.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 5, 2019, 11:31am UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780/3 "2019-04-05T11:31:15Z")

</div>

> [@klaff](#):
>
> Is there a way to make it work without stripping out the units before passing it to Plots?

In the end, somewhere, you have to strip the units because the backends want floating point numbers. What UnitfulPlots.jl does is supply recipes that check unit compatibility, add labels, and then strip and pass to the next stage of the plotting pipeline.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [April 5, 2019, 1:56pm UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780/4 "2019-04-05T13:56:17Z")

</div>

If you just want a solution to plotting things with Unitful values and don’t care about what package you use to do things, current master of Gadfly should “just work” as is. Unfortunately there hasn’t been a release since [the PR adding Unitful support](https://github.com/GiovineItalia/Gadfly.jl/pull/1105) was merged, so you _will_ have to checkout the master branch. Depending on the state of things, you may also have to checkout the master branch of Compose to get Gadfly working properly.

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [April 5, 2019, 7:08pm UTC](https://discourse.julialang.org/t/using-unitful-with-plots/22780/5 "2019-04-05T19:08:02Z")

</div>

Thanks for the replies - will be back to those in the coming days.
