Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Matplotlib contour no data coordinates
#1
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:
İmage


This is data visualized by points:
İmage


This type of graph that I need:
İmage


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.colorbar() 

plt.xlim(xmin, xmax)
plt.ylim(ymin, ymax)
plt.show()
This is CSV data example:
x_pos,y_pos,importance
32,-48,0.87487145766094
32,52,0.43743572883047
32,68,1.127350663193
Full CSV data is here: https://pastebin.com/mYS6LSyG
Quote
#2
bump pls
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Matplotlib Hovering Event displaying (x, y) data RawlinsCross 0 115 Oct-18-2019, 06:13 PM
Last Post: RawlinsCross
  Raycasting GPS coordinates drybulkfreight 10 531 Aug-18-2019, 02:54 PM
Last Post: drybulkfreight
  How to get mouse coordinates on click and release OhNoSegFaultAgain 1 292 May-17-2019, 06:56 PM
Last Post: buran
  Check fast similarity between gps coordinates dervast 0 262 Apr-08-2019, 07:27 PM
Last Post: dervast
  Contour Sort Explain Killing_Machine 0 462 Aug-18-2018, 10:41 AM
Last Post: Killing_Machine
  Updating Point Graphics Coordinates pi314159geek 3 923 Dec-24-2017, 03:42 AM
Last Post: Windspar
  How do I get coordinates for addresses from the csv list? BigD 6 2,022 Dec-02-2017, 09:38 PM
Last Post: BigD
  How to extract (x,y) coordinates of the boundary of a .tif image? Pythonista 23 6,193 Feb-18-2017, 09:17 AM
Last Post: merlem

Forum Jump:


Users browsing this thread: 1 Guest(s)