# Changing units in a DateListPlot

**URL:** <https://community.wolfram.com/t/changing-units-in-a-datelistplot/25764>\
**Category:** Questions\
**Tags:** curated-data, graphics-and-visualization\
**Created:** [July 12, 2025, 12:05am UTC](https://community.wolfram.com/t/changing-units-in-a-datelistplot/25764 "2025-07-12T00:05:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadorfman](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gadorfman](https://community.wolfram.com/u/gadorfman)\
**Post date:** [July 12, 2025, 12:05am UTC](https://community.wolfram.com/t/changing-units-in-a-datelistplot/25764/1 "2025-07-12T00:05:37Z")

</div>

I asked Notebook Assistant to make a nice plot of the United States population from 2014 to 2023 with population in millions. I’d appreciate help with coding to accomplish this. Notebook Assistant generated code that does not work:

```
usPopulationData=CountryData["UnitedStates",{"Population",{2014,2023}}];
usPopulationDataM=usPopulationData /. Quantity[v_,"People"]:>Quantity[v/1000000,"People"];
DateListPlot[
    usPopulationDataM,
    Joined->True,
    PlotTheme->"Scientific",
    Filling->Axis,
    PlotLabel->Style["U.S. Population from 2014 to 2023",Bold,FontColor->DarkBlue,FontSize->16],
    Frame->True,
    FrameStyle->Directive[FontSize->12,Bold], FrameLabel->{Style["Year",Bold,DarkBlue,12],Style["Population (Millions)",Bold,DarkBlue,12]},
    GridLines->Automatic,
    GridLinesStyle->Directive[Dashed,Gray],
    PlotStyle->Directive[Thick,Red],
    ImageSize->Large
]

```

The biggest problem is that the calculation of usPopulationDataM doesn’t work. In fact,  
usPopulationDataM == usPopulationData  
returns True.  
For details about the code and its problems, see attached file NotebookAssitantIssues\_GDorfman\_11jul25.nb .

[NotebookAssitantIssues\_GDorfman\_11jul25.nb](https://community.wolfram.com/uploads/short-url/9IWK5lnvlxxzWG2KNBBbGWXnVad.nb) (67.8 KB)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [July 12, 2025, 10:09am UTC](https://community.wolfram.com/t/changing-units-in-a-datelistplot/25764/2 "2025-07-12T10:09:47Z")

</div>

If you try `usPopulationData // InputForm` you will see that `Quantity` does not appear inside, but rather `QuantityArray`. You can try this:

```
UnitConvert[usPopulationData, "Mega"*"People"]

```

---

<div class="post-metadata">

**Author:** ![gadorfman](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gadorfman](https://community.wolfram.com/u/gadorfman)\
**Post date:** [July 12, 2025, 12:29pm UTC](https://community.wolfram.com/t/changing-units-in-a-datelistplot/25764/3 "2025-07-12T12:29:33Z")

</div>

Gianluca, Thanks. That worked. There was one other, minor problem, which I fixed by changing DarkBlue to Blue. I also changed ImageSize to Medium. The result is in attached file NotebookAssitantIssues\_GDorfman\_12jul25.nb , which is the same as the file I provided yesterday but has a new Subsection called “Modified Code”.

[NotebookAssitantIssues\_GDorfman\_12jul25.nb](https://community.wolfram.com/uploads/short-url/iNOZmlocGx3CdpcNiZKNZMcyvkG.nb) (95.9 KB)
