enthought / enthought/mayavi

Incomplete Data Shown in Mayavi Window Plot

Open
#1,275 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

I am new to Mayavi and wrote some code using ChatGPT for 3D representation of resistance measurements taken over a circular sample.
The values are read out locally from a .csv without headers and with data ranging from -10 to +10 for the first to columns and from 1.7 to 125.7 in the third column.
This is the used code:
```import pandas as pd
from mayavi import mlab
import numpy as np
from scipy.interpolate import griddata

# Specify the file path
file_path = r'Some_Path'

# Read the CSV file without specifying column names
df = pd.read_csv(file_path, header=None, na_values='')

# Drop rows with NaN values (you can choose how to handle missing data)
df.dropna(subset=[0, 1, 2], inplace=True)

# Rename columns if needed
df.columns = ["x", "y", "Resistance"]

# Convert the 'Resistance' column to numeric (in case it's not)
df['Resistance'] = pd.to_numeric(df['Resistance'], errors='coerce')

# Determine unique values of 'x' and 'y'
unique_x = df['x'].unique()
unique_y = df['y'].unique()

# Create a regular grid
X, Y = np.meshgrid(unique_x, unique_y)

# Interpolate 'Resistance' values onto the regular grid
points = df[['x', 'y']].values
values = df['Resistance'].values
Z = griddata(points, values, (X, Y), method='linear')

# Create a Mayavi 3D surface plot with automatic warp scaling
mlab.figure(size=(800, 600))
mlab.surf(X, Y, Z, warp_scale="auto")

# Customize the plot (you can adjust the view as needed)
mlab.xlabel('X')
mlab.ylabel('Y')
mlab.zlabel('Resistance')
mlab.view(azimuth=45, elevation=45)

# Show the plot
mlab.show()
```

Sadly the following image is all I can get out
![Screenshot 2023-09-14 011918](https://github.com/enthought/mayavi/assets/104765088/d8b6b0be-8e70-4887-a493-34c8d969f8c5)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.