Python Forum
x-axis labels with Matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
x-axis labels with Matplotlib
#1
Hopefully this isn't too hard to follow.

Fri_2017 is a list of the first 20 Fridays in 2017 as type datetime.datetime .

I also have this:

for i in range(20):
    random_pnl_list.append(random.randint(-1000,1000))
cumul_pnl_from_random = list(np.cumsum(random_pnl_list))
Now... when I do this in matplotlib:

plt.plot(Fri_2017,cumul_pnl_from_random)
I get x-axis labels at the first and 22nd of the first five months (e.g. 2017-01-01, 2017-01-22, 2017-02-01... 2017-05-01, 2017-05-22). How is this determined--both format and those two particular dates of every month?

I also have this line:

converted_Fri_2017 = [d.strftime('%Y-%m-%d') for d in Fri_2017]
When I do:

plt.plot(converted_Fri_2017,cumul_pnl_from_random)
I get x-axis labels of same format as above (yyyy-mm-dd) but every Friday from 1/6/17 through 5/19/17 (20 total labels). Why the difference?
Reply


Messages In This Thread
x-axis labels with Matplotlib - by Mark17 - Mar-22-2022, 06:26 PM
RE: x-axis labels with Matplotlib - by deanhystad - Mar-22-2022, 09:06 PM
RE: x-axis labels with Matplotlib - by Mark17 - Mar-23-2022, 01:26 PM
RE: x-axis labels with Matplotlib - by deanhystad - Mar-23-2022, 02:56 PM
RE: x-axis labels with Matplotlib - by Mark17 - Mar-23-2022, 03:58 PM
RE: x-axis labels with Matplotlib - by deanhystad - Mar-23-2022, 05:06 PM
RE: x-axis labels with Matplotlib - by Mark17 - Mar-23-2022, 05:45 PM
RE: x-axis labels with Matplotlib - by deanhystad - Mar-23-2022, 05:58 PM
RE: x-axis labels with Matplotlib - by Mark17 - Mar-23-2022, 06:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib x-axis text move bottom upward jacklee26 3 1,139 May-31-2023, 04:28 AM
Last Post: jacklee26
  How can histogram bins be separated and reduce number of labels printed on x-axis? cadena 1 981 Sep-07-2022, 09:47 AM
Last Post: Larz60+
  How to avoid the extra set of y-axis labels? Mark17 9 2,656 May-17-2022, 06:26 PM
Last Post: Mark17
  Floor division problem with plotting x-axis tick labels Mark17 5 2,272 Apr-03-2022, 01:48 PM
Last Post: Mark17
  How to make x-axis readable with matplotlib Mark17 7 4,166 Mar-01-2022, 04:30 PM
Last Post: DPaul
  matplotlib x axis range goes over the set range Pedroski55 5 3,397 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,613 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Graphics Formatting - X-axis Notation and Annotations - Matplotlib silviover_junior 0 1,899 Mar-17-2021, 01:19 PM
Last Post: silviover_junior
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,382 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib x-axis wrong order SchroedingersLion 4 4,436 Feb-23-2021, 05:42 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020