# Covid data scatter plot format

**URL:** <https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247>\
**Category:** Help\
**Created:** [November 4, 2022, 4:58pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247 "2022-11-04T16:58:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HerbyH](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/herbyh/32/7132_2.png) [@HerbyH](https://talk.observablehq.com/u/HerbyH)\
**Post date:** [November 4, 2022, 4:58pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/1 "2022-11-04T16:58:24Z")

</div>

Noob here to D3. [Covid Data Source Scatter Plot / C369 | Observable](https://observablehq.com/d/4ae8f10303323bec)  
I uploaded CovidData.csv  
put into an array and plotted on a scatter plot.

A few requirements:  
Draw a scatter plot with x-axis is Cases, y-axis is Deaths.  
Draw x-axis, y-axis, and ticks on the plot  
Draw all dots in ‘circle’ use color to represent data by  
date

Issues:  
Well my points are on the chart but it looks awful. I need help changing the size of the chart.  
x and y axis seem to be correct. IDK what “ticks” on the plot is referring to.  
How can I draw dots in “‘circle’ use color to represent data by  
date”

---

<div class="post-metadata">

**Author:** ![camdecoster](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/camdecoster/32/6587_2.png) [@camdecoster](https://talk.observablehq.com/u/camdecoster)\
**Post date:** [November 4, 2022, 5:22pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/2 "2022-11-04T17:22:53Z")

</div>

Hello and welcome to the platform! Have you seen the [Plot Cheatsheets](https://observablehq.com/@observablehq/plot-cheatsheets)? They provide some good interactive examples of how to use Plot. You should be able to find some of your answers there. Take a look and let us know if you have any questions.

---

<div class="post-metadata">

**Author:** ![HerbyH](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/herbyh/32/7132_2.png) [@HerbyH](https://talk.observablehq.com/u/HerbyH)\
**Post date:** [November 4, 2022, 5:50pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/3 "2022-11-04T17:50:49Z")

</div>

Thanks for this info. It is informative, but I am still struggling.

---

<div class="post-metadata">

**Author:** ![camdecoster](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/camdecoster/32/6587_2.png) [@camdecoster](https://talk.observablehq.com/u/camdecoster)\
**Post date:** [November 4, 2022, 6:01pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/4 "2022-11-04T18:01:02Z")

</div>

It looks like you’ve taken care of the following:

- Draw a scatter plot with x-axis is Cases, y-axis is Deaths
- Draw x-axis, y-axis, and ticks on the plot

The ticks are the axis marks indicating some value. I’ll take a look at the colors requirement and follow up.

FYI, [this](https://github.com/observablehq/plot) is another good resource for documentation.

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [November 4, 2022, 6:14pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/5 "2022-11-04T18:14:36Z")

</div>

There are a few issues going on here. To address your specific questions first:

- You can adjust the color using the `fill` channel, as you attempted. The problem with `fill: Date` is that `Date` doesn’t refer to the data, rather it’s a built in constructor. Thus, it’s the same for each data point, which is why you get the same color. To change the color, you want `fill: "Date"`.
- I’m not sure what you mean by your Ticks question, as you don’t refer to ticks at any point in your code.
- You can change the size of the chart using the `width` and `height` channels, e.g.:

```auto
Plot.plot({
  width: width, // The built in width macro
  height: 500,
  ...
})

```

I’m not so sure that the plot looks awful; that kinda depends on what you want to illustrate. You might reduce the size of your points and/or add a little opacity. If you want to illustrate how deaths and cases are related, though, then I think a scatter plot like this is perfectly appropriate.

If you want to focus on something else, then you might need another time of plot. I don’t think that coloring by date is likely to be revealing, since you’ve got 4 colors assigned to over 13,000 different points that are all mixed together. You might try faceting like so:

> **[Covid Data Source Scatter Plot](https://observablehq.com/d/f8fbb276dfbae03a)**
>
> A response to this forum post

That notebook also include the option to zoom in on the plots

---

<div class="post-metadata">

**Author:** ![camdecoster](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/camdecoster/32/6587_2.png) [@camdecoster](https://talk.observablehq.com/u/camdecoster)\
**Post date:** [November 4, 2022, 6:44pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/6 "2022-11-04T18:44:50Z")

</div>

I think that a good option (after fixing the “Date” reference as described above) would be to add a legend. You can do that like this:

```javascript
Plot.plot({
  color: {
    legend: true
  },
  marks: [
    Plot.dot(coviddata, {x: "cases", y: "deaths", fill: "Date"}),
  ]
})

```

And I agree that it doesn’t look awful. It’s just a work in progress. You’ll get it where you want it soon.

---

<div class="post-metadata">

**Author:** ![HerbyH](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/herbyh/32/7132_2.png) [@HerbyH](https://talk.observablehq.com/u/HerbyH)\
**Post date:** [November 4, 2022, 6:52pm UTC](https://talk.observablehq.com/t/covid-data-scatter-plot-format/7247/7 "2022-11-04T18:52:11Z")

</div>

\*celebrating  
I just added a legend and saw your suggestion. I am noob JS too.
