# Plotlyjs x values display

**URL:** https://discourse.julialang.org/t/plotlyjs-x-values-display/89688
**Category:** Visualization
**Tags:** plotting, dates, plotlyjs
**Created:** [November 3, 2022, 3:09am UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688 "2022-11-03T03:09:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Stephen](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Stephen](https://discourse.julialang.org/u/Stephen)
#### Post date: [November 3, 2022, 3:09am UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/1 "2022-11-03T03:09:16Z")

</div>

![截圖_選取範圍_20221102220420](https://global.discourse-cdn.com/julialang/original/3X/8/8/883b487751ee30b14ac370bac814559303c9d47c.png)  
 ![截圖_選取範圍_20221102220432](https://global.discourse-cdn.com/julialang/original/3X/b/9/b9cacc2ba8766e8c69f421cf6cf7492e12e44c10.png)  
here is the code:

```julia
DateTick = x[1]:Dates.Month(6):x[end]
DateTick2 = Dates.format.(DateTick,"Y-m")
p1 = scatter(x, y1, xticks = (DateTick, DateTick2),
      title = "Money supply", xrotation=-45, legend = :topleft)

```

I want the x value of 2002-7 ( and others ) to display correctly when hovering on those points

---

<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: [November 3, 2022, 9:32am UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/2 "2022-11-03T09:32:56Z")

</div>

Could you please mention how is recorded date in your CSV file I suppose you are reading the get df[!, :date]?

Take a look here [https://plotly.com/julia/time-series/](https://plotly.com/julia/time-series/) how the tickformat is set for date.

---

<div class="post-metadata">

### Author: ![Stephen](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Stephen](https://discourse.julialang.org/u/Stephen)
#### Post date: [November 3, 2022, 11:22am UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/3 "2022-11-03T11:22:26Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/0/e/0e303d7e951f3900718489d4e864410b24024841.png)

this is reading from csv file,

`money = CSV.read(“货币供应量.csv”,DataFrame)

x = money.日期  
`

---

<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: [November 3, 2022, 4:18pm UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/4 "2022-11-03T16:18:46Z")

</div>

I created such a csv file with date containing only year and month, but the date is automatically read in the form yy-mm-01. (CSV v0.10.4, DataFrames v1.3.4).  
But I succeeded to get displayed your format, on hover, using `customdata` and `hovertemplate`:

```julia
fig= Plot(scatter(x=df[!, :date], y= df[!, :GOOG], mode="markers", marker_size=16, 
                          customdata=df[:, :date], 
                          hovertemplate="(%{customdata|%Y-%m}, %{y})<extra></extra>"),
                          Layout(width=600, height=350))

```

---

<div class="post-metadata">

### Author: ![Stephen](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Stephen](https://discourse.julialang.org/u/Stephen)
#### Post date: [November 4, 2022, 11:48am UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/5 "2022-11-04T11:48:40Z")

</div>

ha, I see, your code works, Thank you !  
Should I use PlotlyJS instead of `using Plots`, `plotlyjs()` as backend ? when I use `plotlyjs()` backend it shows as this

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/3/d36b8f088eea02dc76971f8b8c4dfddbb6ca37e4.png)

BTW, what is the difference of

```julia
using Plots
plotlyjs()

```

and

```julia
using PlotlyJS

```

?  
when using plotlyjs as backend, should I must use specific syntax and format of `PlotlyJS` rather than general syntax of `Plots`？

---

<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: [November 4, 2022, 12:02pm UTC](https://discourse.julialang.org/t/plotlyjs-x-values-display/89688/6 "2022-11-04T12:02:45Z")

</div>

Plots.jl and PlotlyJS.jl are two different plotting packages, with distinct functions and plot layouts. But Plots can use plotlyjs() as backend.
