Skip to main content

All Questions

Tagged with
15 votes
1 answer
35k views

Python color map but with all zero values mapped to black

I have a square array of elements which correspond to lattice sites. Some of the elements are zero and the rest vary between 1 and about 2700. Using imshow and the OrRd colour map, I want all lattice ...
3 votes
2 answers
4k views

How do I create a 3D line plot in matplotlib from the data in arrays?

I have numerically solved the Lorenz equations using SciPy with the script: # Lorenz Equations SciPy solver import numpy as np from scipy import integrate from math import cos from matplotlib import ...
1 vote
1 answer
46 views

Iteration of a graph approximation

The code below runs a model based on a graph generated by the solution to a system of differential equations and shows one with random 5% error added to the points. How would I iterate this process (...
1 vote
0 answers
41 views

How to plot only a certain area of data?

I am facing a problem that I can't solve. I have radar data, from which I want to plot the grid structure (rectangles) of a certain area. So far, I have the following: #-- Get coordinates in the ...
46 votes
4 answers
135k views

Overlay an image segmentation with numpy and matplotlib

I am trying to overlay two images. The first one is a 512x512 NumPy array (from a CT image). The second one is also a 512x512 NumPy array but I am just interested in the pixels where the value is ...
0 votes
1 answer
50 views

Is there a way to print a desired x and y value directly from a graph using arrays in python? I also need to have the x axis at y = 0

Current plot with markers import numpy as np import matplotlib.pyplot as plt import math as mth x = np.array([0.0012,0.0006,0.0004,0.0003,0.00024,0.0002]) y = np.array([-160,-35,-4.2,9.0,16.9,21.3]) ...
1 vote
1 answer
283 views

Reading arrays from txt file in python to plot a graph

I'm new to python and want to plot a graph using data stored in arrays on a txt file... content in the txt file ar just the arrays... nothing else.. exemple: arrays.txt [0, 1, 10, 5, 40, 1, 70] [12, ...
0 votes
0 answers
38 views

Animation of an array with matplotlib library

I want to animate my array as a scatter plot, this is the shape of my data: data = np.array([[[[1], [2], [7], [1]], [[2], [4], [9], [1]]], [[[5], [2], [8], [1]], ...
-1 votes
2 answers
245 views

How to reverse the slope of a graphed line

I'm trying to make a simple budget line graph that you would see in an economics class. But I need the slope of my line to be from 60 to 15 (inverse of what it is now). I tried inversing the axis ...
-1 votes
1 answer
41 views

Splitting a large 3D array and plotting into colormap

I have some 3D structured array data and i want to process them into colormaps. The array is very huge, and it looks like below when i print it. [[[9.24908975e-05 9.24908975e-05 9.24908975e-05 ... 9....
55 votes
1 answer
261k views

TypeError: Invalid dimensions for image data when plotting array with imshow()

For the following code # Numerical operation SN_map_final = (new_SN_map - mean_SN) / sigma_SN # Plot figure fig12 = plt.figure(12) fig_SN_final = plt.imshow(SN_map_final, interpolation='nearest') ...
2 votes
0 answers
29 views

How to convert a 3D plot into a 2D filled contour [duplicate]

I have a 3D plot that looks quite nice, and I'd like to convert this to a 2D filled contour plot, but I'm not quite sure how to do that. Here is my setup import numpy as np from mpl_toolkits.mplot3d ...
2 votes
2 answers
625 views

Difference between plotting the same data from a csv file and from array?

I plotted data from CSV file and I converted the same CSV file into NumPy array and plotted the same data. However, I get different graphs, which is confusing and can someone help me if I have made a ...
22 votes
5 answers
66k views

how to save an array as a grayscale image with matplotlib/numpy?

I am trying to save a numpy array of dimensions 128x128 pixels into a grayscale image. I simply thought that the pyplot.imsave function would do the job but it's not, it somehow converts my array into ...
0 votes
1 answer
102 views

How to assign scatter markers by dataframe column? How to avoid TypeError: unhashable type: 'Series' when creating string array from dataframe?

I'm trying to scatter plot data by year (column of dataframe) and assign marker type by detector used (column of dataframe). The following code generates the error 'TypeError: unhashable type: 'Series'...

15 30 50 per page
1
2 3 4 5
36