I want to create a two-dimensional map using python.

Asked 2 years ago, Updated 2 years ago, 93 views

I would like to graph the intensity in the z-axis direction on the xy plane using two-dimensional mapping.
At that time, I imagine that the dots between the data will be interpolated and connected smoothly.

The data is stored in CSV format, where the first row contains values on the x-axis and the first column contains values on the y-axis.
An image-like CSV that contains the corresponding strength for each row and column.

Enter a description of the image here

Python, Matplotlib Data Visualization has been diverted to:

import path 
import numpy as np
import matplotlib.pyplot asplt

# data loading
p2=np.loadtxt('Book1.csv', delimiter=',')

# axis creation
xx,yy=[],[]
x = p2 [0,:]
y = p2 [:,0]
x = [1: ]
y = [1: ]

for num in range (len(x)):
    xx.append(x)
for num in range (len(y)):
    yy.append(y)
X=np.array(xx)
Y = np.array(yy).T

# Create dimensional array in data
p2 = np.delete(p2,0,1)
p2 = np.delete(p2,0,0)

# drawing
plt.contourf(X,Y,p2,100)
plt.xlabel('x')
plt.ylabel('y')
plt.colorbar()
plt.show()

However, syntax has an error in the following description.I don't understand the necessity of this statement in the first place. Do I have to?

 x = [1:]
y = [1: ]

I would like to ask you to code it so that it can be mapped in two dimensions somehow.
Also, if there is another efficient way, you can write it down.
I would appreciate it if you could let me know.

python matplotlib

2022-09-30 19:37

1 Answers

It's just typo or copy error.

This part of the question is:

 x = [1:]
y = [1: ]

The relevant parts of the reference article are as follows:

y=y[1:]
z=z[1:]

Therefore, the source of the question should be as follows:

 x=x[1:]
y=y[1:]


2022-09-30 19:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.