I have written the following code to plot lat,long and colorbar for temperature within certain height constraints using the following code -
import os
import pandas as pd
import matplotlib.pyplot as plt
# Path to the combo folder
combo_folder = '/home/dev/Desktop/Venus/Data/combo'
# constraints
height_min = 40
height_max = 60
venus_radius = 6051.8
# Calculate the aspect ratio of the image
# image = plt.imread('/home/dev/Desktop/Venus/Images/venmap2.tif')
image = plt.imread('/home/dev/Desktop/Venus/Images/venmap.gif')
# image = plt.imread(image_path)
image_aspect_ratio = image.shape[1] / image.shape[0]
# Create a figure with dimensions based on the image aspect ratio
width = 30
height = width / image_aspect_ratio
fig, ax = plt.subplots(figsize=(width, height))
# Display the image as the background
ax.imshow(image, extent=[0, 360, -90, 90], aspect='auto')
# Iterate over the files in the combo folder
for filename in os.listdir(combo_folder):
if filename.endswith('.csv'):
file_path = os.path.join(combo_folder, filename)
# Load the combined dataset
df = pd.read_csv(file_path)
# Extract the required columns
latitude = df['LATITUDE']
longitude = df['LONGITUDE']
temperature = df['TEMPERATURE_MEDIUM_TEMPERATURE_AT_BOUNDARY']
height = df['RADIUS'] - venus_radius
# Filter data based on height constraints
mask = (height >= height_min) & (height <= height_max)
latitude = latitude[mask]
longitude = longitude[mask]
temperature = temperature[mask]
# Plot latitude, longitude, and temperature
scatter = ax.scatter(longitude, latitude, c=temperature,s=200, cmap='viridis', alpha=0.7)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
ax.set_title('Latitude and Longitude with Temperature (Height: {} to {})'.format(height_min, height_max))
# Add a colorbar
cbar = fig.colorbar(scatter, ax=ax, label='Temperature (°C)')
# Show the plot
plt.show()
And, I have the following code which shows the lat,long,height as 3d plot with temp as the colorbar
venus_radius = 6051.8
import os
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Path to the combo folder
combo_folder = '/home/dev/Desktop/Venus/Data/combo'
# Height constraints
height_min = 40
height_max = 60
# Create a figure and a 3D axis
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Set axis limits
ax.set_xlim(0, 360)
ax.set_ylim(-90, 90)
ax.set_zlim(0, 90)
# Iterate over the files in the combo folder
for filename in os.listdir(combo_folder):
if filename.endswith('.csv'):
file_path = os.path.join(combo_folder, filename)
# Load the combined dataset
df = pd.read_csv(file_path)
# Extract the required columns
latitude = df['LATITUDE']
longitude = df['LONGITUDE']
radius = df['RADIUS']
temperature = df['TEMPERATURE_MEDIUM_TEMPERATURE_AT_BOUNDARY']
height = radius - venus_radius
# Filter data based on height constraints
mask = (height >= height_min) & (height <= height_max)
latitude = latitude[mask]
longitude = longitude[mask]
temperature = temperature[mask]
height = height[mask]
# Plot latitude, longitude, and temperature within the height range
scatter = ax.scatter(longitude, latitude, height, c=temperature, cmap='viridis', alpha=0.7)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
ax.set_zlabel('Height')
ax.set_title('Latitude, Longitude, and Height with Temperature (Height: {} to {})'.format(height_min, height_max))
# Add a colorbar
cbar = fig.colorbar(scatter, ax=ax, label='Temperature (°C)')
# Show the plot
plt.show()
The image I am using as the background is - the image I am using as background
I am trying to maintain the aspect ratios in the 2 d plot as it is, just trying to get a plot which integrates the two. essentially the image as the backround of the surface for lat,long, while keeping the aspect ratio settings as in the 2d plot.