Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Matplotlib contour no data coordinates
I have problem with Matplotlib contour graph. I have graph size (100x100). All "importance" values of CSV which are >0 should be red. Every value <0 should be blue.

My question is, if is possible to have places with no data (no coordinates in CSV) in white color. Now it's couting some average color from nearby points.

This is situation which I have right now:

This is data visualized by points:

This type of graph that I need:

Is possible to get similar graph by using Contour?

This is my code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
import pandas as pd

csv_filename = 'data.csv'
df = pd.read_csv(csv_filename)

data = [df.x_pos, df.y_pos]
x = df.x_pos
y = df.y_pos
z = df.importance

ny, nx = 1000, 1000
xmin, xmax = 0, 100
ymin, ymax = 0, 100

xi = np.linspace(xmin, xmax, nx)
yi = np.linspace(ymin, ymax, ny)

zi = ml.griddata(x, y, z, xi, yi, interp='linear')

plt.contour(xi, yi, zi, 1, linewidths = 0, colors = 'k')
plt.pcolormesh(xi, yi, zi, vmin=-1, vmax=1, cmap = plt.get_cmap('bwr'))

#plt.scatter(x, y, marker = 'o', c = z, s = 10, vmin=-1, vmax=1, cmap = plt.get_cmap('bwr'))

plt.xlim(xmin, xmax)
plt.ylim(ymin, ymax)
This is CSV data example:
Full CSV data is here:
bump pls

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Matplotlib ImportError robertinoc 4 178 Jun-14-2019, 09:11 AM
Last Post: snippsat
  Matplotlib animation problem Potatoez 1 253 May-21-2019, 03:58 PM
Last Post: Potatoez
  MatplotLib Sliders punksnotdead 4 189 May-18-2019, 08:45 PM
Last Post: punksnotdead
  How to get mouse coordinates on click and release OhNoSegFaultAgain 1 97 May-17-2019, 06:56 PM
Last Post: buran
  Animation using matplotlib query JohnDoe 0 80 May-09-2019, 08:07 PM
Last Post: JohnDoe
  How to switch table area coordinates in Python Camelot and Tabula-Py john5 0 155 May-08-2019, 04:31 PM
Last Post: john5
  How do i get matplotlib event handling to work? jenya56 3 266 Apr-24-2019, 06:53 PM
Last Post: jenya56
  Check fast similarity between gps coordinates dervast 0 119 Apr-08-2019, 07:27 PM
Last Post: dervast
  Matplotlib 3d voxels animation jasiekkm 0 113 Apr-07-2019, 07:44 AM
Last Post: jasiekkm
  Create Animated Scatter plot in 3d using matplotlib in python barry76 0 209 Mar-29-2019, 12:13 PM
Last Post: barry76

Forum Jump:

Users browsing this thread: 1 Guest(s)