Python Forum
How to invert scatter plot axis
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to invert scatter plot axis
#1
Hi all,

Here's some code:

import pandas as pd
import matplotlib.pyplot as plt
import time
import numpy as np

start_time = time.time()

df = pd.DataFrame(columns=['DTE', 'Long Delta', 'Short Delta', 'Delta Spread'])

# Checking all permutations covered by program:  
for dte in range(30,61):
    long_delta = np.arange(-0.1,-0.35,-0.05)
    short_delta = np.arange(-0.25,-0.50,-0.05)
    if dte == 30:
        for ld in long_delta:
            for sd in short_delta:  
                plt.scatter(ld,sd)
                
plt.tight_layout() #to prevent axis labels from being cut off in saved figure
plt.xlabel('Long Delta')
plt.ylabel('Short Delta')
end_time = time.time()
print('Elapsed time is {:.0f}ms'.format(1000*(end_time-start_time)))
How do I reverse the axes on the graph so they go from largest to smallest (left to right and down to up)?

Mark
Reply


Messages In This Thread
How to invert scatter plot axis - by Mark17 - Sep-20-2021, 06:13 PM
RE: How to invert scatter plot axis - by jefsummers - Sep-20-2021, 06:52 PM
RE: How to invert scatter plot axis - by Mark17 - Sep-22-2021, 11:29 AM
RE: How to invert scatter plot axis - by jefsummers - Sep-22-2021, 04:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked plt.scatter() errors asja2010 0 1,524 Oct-13-2022, 08:15 AM
Last Post: asja2010
  Making a plot with secondary y-axis bigger snkm 0 1,150 Feb-10-2022, 09:40 AM
Last Post: snkm
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,451 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  Animated scatter plot maximan 0 1,664 Jan-18-2021, 03:53 PM
Last Post: maximan
  How to plot intraday data of several days in one plot mistermister 3 2,949 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  5 variants to invert dictionaries with non-unique values Drakax1 2 2,642 Aug-31-2020, 11:40 AM
Last Post: snippsat
  Difference Between Figure Axis and Sub Plot Axis in MatplotLib JoeDainton123 2 2,508 Aug-21-2020, 10:17 PM
Last Post: JoeDainton123
  Group scatter plots Mekala 0 1,675 Jul-23-2020, 02:18 PM
Last Post: Mekala
  Invert Pillow image colours chesschaser 5 3,904 Jul-11-2020, 02:59 PM
Last Post: chesschaser
  how to nest loop for 4*4 scatter plot kassamohammed 0 2,593 Jun-23-2020, 09:47 AM
Last Post: kassamohammed

Forum Jump:

User Panel Messages

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