# Using Manipulate for ploting

**URL:** <https://discourse.julialang.org/t/using-manipulate-for-ploting/48305>\
**Category:** General Usage\
**Tags:** question, package, plotting\
**Created:** [October 13, 2020, 3:21pm UTC](https://discourse.julialang.org/t/using-manipulate-for-ploting/48305 "2020-10-13T15:21:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kantvishu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kantvishu/32/18645_2.png) [@Kantvishu](https://discourse.julialang.org/u/Kantvishu)\
**Post date:** [October 13, 2020, 3:21pm UTC](https://discourse.julialang.org/t/using-manipulate-for-ploting/48305/1 "2020-10-13T15:21:13Z")

</div>

Hello Everyone, I am trying to use interactive plotting using manipulate function (Pkg-Ineract) on Juno-Atom. I am unable to plot x-axis in dynamic plot using @manipulate function. I am pasting my static plot and dynamic plot code and it’s Gif-(I can’t paste static plot picture in this post as I am new user so I am not allowed to attach more than one item). In short, I want the same X-axis in the dynamic plot as in static plot. When I try plotting X-axis in dynamic part I get blank output.

Static code

```julia
plot(US_data_T_confirmed[8:end],US_data_new_cases, m=:o )
ylabel!("New Confirmed Cases in Past Seven Days")
xlabel!("Total Confirmes Cases")
title!("COVID-19 cases in US")

```

Dynamic code

```julia
using Plots 
using Interact
@manipulate for Days in 1:length(dates)
     plot(US_data_new_cases[1:Days],m=:o)
     xlims!(1,length(dates))
     ylabel!("New Confirmed Cases in Past Seven Days")
     title!("COVID-19 cases")
end

```

 ![dynamic-Covid-plot-](https://global.discourse-cdn.com/julialang/original/3X/2/9/290af7ca30cae4ff866e2505c1483ac9da5b1f17.gif)

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [October 13, 2020, 3:30pm UTC](https://discourse.julialang.org/t/using-manipulate-for-ploting/48305/2 "2020-10-13T15:30:01Z")

</div>

This should work:

```julia
using Plots 
using Interact
@manipulate for Days in 1:length(dates)
     p = plot(US_data_new_cases[1:Days],m=:o)
     xlims!(1,length(dates))
     ylabel!("New Confirmed Cases in Past Seven Days")
     title!("COVID-19 cases")
     display(p)
end

```

---

<div class="post-metadata">

**Author:** ![Kantvishu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kantvishu/32/18645_2.png) [@Kantvishu](https://discourse.julialang.org/u/Kantvishu)\
**Post date:** [October 13, 2020, 4:33pm UTC](https://discourse.julialang.org/t/using-manipulate-for-ploting/48305/3 "2020-10-13T16:33:07Z")

</div>

Sorry, it did not work! I just got the slider as output! I need to use variable `US_data_T_confirmed[8:end]` on the x-axis. I don’t see; you used this variable in your code.

---

<div class="post-metadata">

**Author:** ![Kantvishu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kantvishu/32/18645_2.png) [@Kantvishu](https://discourse.julialang.org/u/Kantvishu)\
**Post date:** [October 13, 2020, 7:15pm UTC](https://discourse.julialang.org/t/using-manipulate-for-ploting/48305/4 "2020-10-13T19:15:44Z")

</div>

I found my problem: I was inputing a column vector for x-axis. Inputing row vector using transpose gave me expected output. Following code worked:

```julia
T_US=transpose(US_data_T_confirmed[8:end])
using Plots 
using Interact
@manipulate for Days in 1:length(dates)
     plot(T_US[1:Days],US_data_new_cases[1:Days],m=:o)
     xlims!(T_US[1],T_US[end])
     ylabel!("New Confirmed Cases in Past Seven Days")
     title!("COVID-19 cases")
end

```
