0
$\begingroup$

I have the following code:

names = CountryData[];
data = CountryData[#, {"Population", {1920,2010}}] &/@ names;
cleaned = DeleteMissing[data/.{}->Nothing];
sum = TimeSeriesThread[Total, cleaned];
DateListLogPlot[sum, AxesLabel->{"Time (Years)", "Log(Population)"}]

This gives the estimated world population increase as a function of time on a Log plot.

I would like to be able to explicitly label my axes, but this doesn't seem to work with DateListPlot or DateListLogPlot. AxesLabel doesn't throw an error when passed to either of these functions, but it also doesn't result in the desired output.

Checking over the docs for DateListPlot, AxesLabel doesn't appear as an option, and none of the example plots have y-axis labels.

Am I missing something obvious, or is there really no way to title/label the y-axis in DateListPlot or DateListLogPlot?

$\endgroup$

1 Answer 1

1
$\begingroup$
names = CountryData[];
data = CountryData[#, {"Population", {1920, 2010}}] & /@ names;
cleaned = DeleteMissing[data /. {} -> Nothing];
sum = TimeSeriesThread[Total, cleaned];

DateListLogPlot[sum,
 FrameLabel -> {{"one", "two"}, {"three", "four"}},
 LabelStyle -> Directive[Red, Bold, 16],
 PlotTheme -> "Detailed"]

You can search for more options for Frame on the Plot page, if need be. I hope it helps you.

enter image description here

$\endgroup$
3
  • $\begingroup$ FrameLabel -> {{"one", None}, {"three", None}} in case you want to skip labels. $\endgroup$
    – Syed
    Commented Aug 24, 2021 at 16:45
  • $\begingroup$ Interesting. I wasn't aware of the Frame or FrameLabel options. It seems like DateListPlot Automatically adds Frame->True, but even if you pass Frame->False along with an AxesLabel argument, it doesn't label the axes. Your solution works great though! $\endgroup$ Commented Aug 24, 2021 at 17:23
  • $\begingroup$ The documentation on these commands needs an update to include Frame related options. You asked if you were "missing something obvious". Obviously not. $\endgroup$
    – Syed
    Commented Aug 25, 2021 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.