Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding text to plots
#1
I am trying to add text to my plots in the upper right of the plot. The issue is the plots vertical axis is constantly changing. Is there a way to lock the text to the same spot regardless of the axis change?

What I have been trying is shown below. The text(1., 1.) portion of the code will place text at that data location on the plot, instead of the upper right corner.

    with PdfPages('Data Comparison Ethan Text Files.pdf') as pdf:
        text_data_file = files._textfile_data(textfile1, textfile2, textfile3, textfile4, textfile5)
        current_key = iter(dictionary)
        n = dictionary._sample_size(key_filename) * dictionary._revolutions(etim_filename)
        for x in range(len(dictionary._key_data(key_filename))-1):
            plt.plot(range(0,n), dictionary[next(current_key)], linewidth = 0.25)
            plt.plot(range(0,n), text_data_file[:,x], ':', linewidth = 0.25)
            ei = sum(text_data_file[:,x]) - sum(dictionary[dictionary._key_data(key_filename)[x]])
            MAE = abs(ei)/n
            plt.text(1., 1., 'MAE is: %s' %(MAE), fontsize = 'x-small')

Sorry guys, found the mistake. Should have been using figtext(), instead of text().
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple Plots in Spyder PythonAndMe2023 0 977 Feb-03-2023, 07:00 PM
Last Post: PythonAndMe2023
  Help adding prompt text in a Layout using Rich TUI Extra 2 1,766 May-23-2022, 07:15 PM
Last Post: Extra
  Subplot - Plotting 4 plots on the same row Menthix 1 1,518 Nov-07-2021, 09:03 PM
Last Post: deanhystad
  Sharing X Axis in Sub plots JoeDainton123 1 2,260 Aug-22-2020, 04:11 AM
Last Post: deanhystad
  Help With Sub Plots JoeDainton123 0 1,757 Aug-20-2020, 10:48 PM
Last Post: JoeDainton123
  Group scatter plots Mekala 0 1,718 Jul-23-2020, 02:18 PM
Last Post: Mekala
  Adding markers to Folium map only adding last element. tantony 0 2,223 Oct-16-2019, 03:28 PM
Last Post: tantony
  Saving multiple plots as pdf mohd_umair 0 3,411 Apr-28-2019, 01:21 PM
Last Post: mohd_umair
  Adding a paragraph of text before an exercise oldDog 5 3,730 May-22-2018, 06:57 PM
Last Post: oldDog
  Can't locate plots package BobLoblaw 12 11,222 Oct-04-2017, 11:56 PM
Last Post: BobLoblaw

Forum Jump:

User Panel Messages

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