Python Forum
matplotlib x-axis text move bottom upward
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matplotlib x-axis text move bottom upward
#1
Does anyone know how to resize the bottom of my x-axis u, it seem like the x-axis all text word is showing all of them out.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

# Read the Excel file into a pandas DataFrame
data = pd.read_excel('1.xlsx')

# Extract datetime and Tput columns
datetime = data['datetime']
tput = data['Tput']

# Convert the datetime column to numeric values using NumPy
x = np.arange(len(datetime))

# Plot the line graph
plt.plot(datetime, tput)
plt.xlabel('time')
plt.ylabel('Tput')
plt.title('TPUT')

plt.xticks(rotation=90, fontsize=12)
plt.show()
My excel contains data like this:
datetime Tput
20230419.172914.301607 0.000287
20230419.172924.301733 0.000993
20230419.172934.301880 0.00074
20230419.172944.302017 0.00074



please refer to my attached xaxis.PNG as you can see below xaxis text or word beginning seem not showing, how to show.

If use the setting to set like adjust_bottom.PNG , when moving the bottom to right the word will display, but the whole page will effect.

is there any way to solve showing the xaxis word

Attached Files

Thumbnail(s)
       
Reply
#2
Try this perhaps.
Reply
#3
(May-30-2023, 12:08 PM)Gribouillis Wrote: Try this perhaps.

i try using
 plt.tight_layout() 
xaxis word will show
but is there any method to adjust the graph like attached picture resize.PNG

Attached Files

Thumbnail(s)
   
Reply
#4
I try with this seems like it work:
plt.figure(figsize=(15, 6.5))
x = np.arange(len(datetime))
plt.figure(figsize=(15, 6.5))
# Plot the line graph
plt.plot(datetime, tput, label='DL')
plt.xlabel('time')
plt.ylabel('Tput')
plt.title('TPUT')
plt.xticks(rotation=90, fontsize=12)
plt.legend()
plt.tight_layout() 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,396 Aug-15-2022, 12:00 PM
Last Post: khadija
  python-docx regex : Browse the found words in turn from top to bottom Tmagpy 0 1,539 Jun-27-2022, 08:45 AM
Last Post: Tmagpy
  x-axis labels with Matplotlib Mark17 8 2,242 Mar-23-2022, 06:10 PM
Last Post: Mark17
  How to make x-axis readable with matplotlib Mark17 7 3,941 Mar-01-2022, 04:30 PM
Last Post: DPaul
  matplotlib x axis range goes over the set range Pedroski55 5 3,228 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,394 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Graphics Formatting - X-axis Notation and Annotations - Matplotlib silviover_junior 0 1,793 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,255 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib x-axis wrong order SchroedingersLion 4 4,276 Feb-23-2021, 05:42 PM
Last Post: nilamo
  Is there a way to move text created by turtle.write()? derekered 7 5,981 Dec-16-2020, 09:44 AM
Last Post: itexamples

Forum Jump:

User Panel Messages

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