I have two arrays and I take their logs. When I do that and try to plot their scatter plot, I get this error:
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/pyplot.py", line 2192, in scatter
ret = ax.scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, ...
I have an array with two columns in numpy. For example:
a = array([[1, 5, nan, 6],
[10, 6, 6, nan]])
a = transpose(a)
I want to efficiently iterate through the two columns, a[:, 0] and a[:, 1] and remove any pairs that meet a certain condition, in this case if they are NaN. The obvious way I can think of is:
new_a = []
fo...
I am trying to plot the following numbers on a log scale as a scatter plot in matplotlib. Both the quantities on the x and y axes have very different scales, and one of the variables has a huge dynamic range (nearly 0 to 12 million roughly) while the other is between nearly 0 and 2. I think it might be good to plot both on a log scale....
How can I quickly extract two rows of a scipy.sparse.lil_matrix and apply bitwise operations on them? I've tried:
np.bitwise_and(A[1,:], A[2,:])
but NumPy seems to want an array type according to the documentation.
...
I have a 2-d array containing pairs of values and I'd like to make a boxplot of the y-values by different bins of the x-values. I.e. if the array is:
my_array = array([[1, 40.5], [4.5, 60], ...]])
then I'd like to bin my_array[:, 0] and then for each of the bins, produce a boxplot of the corresponding my_array[:, 1] values that fall ...
I have an array like:
a = array([[1,2,3],[3,4,5],[4,5,6]])
what's the most efficient way to slice out a 1x2 array out of this that has only the first two columns of "a"?
I.e.,
array([[2,3],[4,5],[5,6]]) in this case.
thanks.
...
Hi,
i have an numpy array which represents multiple x-intervals of a function:
In [137]: x_foo
Out[137]:
array([211, 212, 213, 214, 215, 216, 217, 218, 940, 941, 942, 943, 944,
945, 946, 947, 948, 949, 950])
as you can see, in x_foo are two intervals: one from 211 to 218, and one from 940 to 950. these are intervals, which i w...
I'm trying to port a program which uses a hand-rolled interpolator (developed by a mathematician colleage) over to use the interpolators provided by scipy. I'd like to use or wrap the scipy interpolator so that it has as close as possible behavior to the old interpolator.
A key difference between the two functions is that in our origina...
Hi,
Lately, I've been looking into an implementation of an incremental PCA algorithm in python - I couldn't find something that would meet my needs so I did some reading and implemented an algorithm I found in some paper. Here is the module's code - the relevant paper on which it is based is mentioned in the module's documentation.
I w...
I have access to a cluster of Unix machines, but they don't have the software I need (numpy, scipy, matplotlib, etc), so I have to install them by myself (I don't have root permissions, either, so commands like apt-get or yast don't work).
In the worst case, I will have to compile them all from source. Is there any better way to proceed...
I am binning a 2d array (x by y) in Python into the bins of its x value (given in "bins"), using np.digitize:
elements_to_bins = digitize(vals, bins)
where "vals" is a 2d array, i.e.:
vals = array([[1, v1], [2, v2], ...]).
elements_to_bins just says what bin each element falls into. What I then want to do is get a list whose len...
I have two floats in Python that I'd like to subtract, i.e.
v1 = float(value1)
v2 = float(value2)
diff = v1 - v2
I want "diff" to be computed up to two decimal places, that is compute it using %.2f of v1 and %.2f of v2. How can I do this? I know how to print v1 and v2 up to two decimals, but not how to do arithmetic like that.
The ...
Suppose that I have two numpy arrays of the form
x = [[1,2]
[2,4]
[3,6]
[4,NaN]
[5,10]]
y = [[0,-5]
[1,0]
[2,5]
[5,20]
[6,25]]
is there an efficient way to merge them such that I have
xmy = [[0, NaN, -5 ]
[1, 2, 0 ]
[2, 4, 5 ]
[3, 6, NaN]
[4, NaN, NaN]
...
Hi,
Has anyone used scipy-cluster for python? I am trying to compile its source code with python 2.6 but I get some irrelevant errors. has someone had the same problem?
...
How can I sort an array in numpy by the nth column? e.g.
a = array([[1,2,3],[4,5,6],[0,0,1]])
I'd like to sort by the second column, such that I get back:
array([[0,0,1],[1,2,3],[4,5,6]])
thanks.
...
I am using matplotlib in Python to plot a line with errorbars as follows:
plt.errorbar(xvalues, up_densities, yerr=ctl_sds, fmt='-^', lw=1.2, markersize=markersize,
markeredgecolor=up_color, color=up_color, label="My label", clip_on=False)
plt.xticks(xvalues)
I set the ticks on the x-axis using "xticks". However, the error b...
I'm having some issues with my first attempts at using matplotlib and scipy to make some scatter plots of my data (too many variables, trying to see many things at once). Here's some code of mine that is working fairly well...
import numpy
from scipy import *
import pylab
from matplotlib import *
import h5py
FileID = h5py.File('3DiPVD...
I am having trouble reading a csv file, delimited by tabs, in python. I use the following function:
def csv2array(filename, skiprows=0, delimiter='\t', raw_header=False, missing=None, with_header=True):
"""
Parse a file name into an array. Return the array and additional header lines. By default,
parse the header lines into ...
given a list of python strings, how can I automatically convert them to their correct type? Meaning, if I have:
["hello", "3", "3.64", "-1"]
I'd like this to be converted to the list
["hello", 3, 3.64, -1]
where the first element is a stirng, the second an int, the third a float and the fourth an int.
how can I do this? thanks....
I have a dictionary whose keys are strings and values are numpy arrays, e.g.:
data = {'a': array([1,2,3]), 'b': array([4,5,6]), 'c': array([7,8,9])}
I want to compute a statistic between all pairs of values in 'data' and build an n by x matrix that stores the result. Assume that I know the order of the keys, i.e. I have a list of "la...