Matplotlib plots: removing axis, legends and white spaces

I think that the command axis(‘off’) takes care of one of the problems more succinctly than changing each axis and the border separately. It still leaves the white space around the border however. Adding bbox_inches=’tight’ to the savefig command almost gets you there, you can see in the example below that the white space left is much smaller, but still present. … Read more

No Multiline Lambda in Python: Why not?

Look at the following: Is this a lambda returning (y, [1,2,3]) (thus map only gets one parameter, resulting in an error)? Or does it return y? Or is it a syntax error, because the comma on the new line is misplaced? How would Python know what you want? Within the parens, indentation doesn’t matter to python, so you … Read more

What are the differences between numpy arrays and matrices? Which one should I use?

Numpy matrices are strictly 2-dimensional, while numpy arrays (ndarrays) are N-dimensional. Matrix objects are a subclass of ndarray, so they inherit all the attributes and methods of ndarrays. The main advantage of numpy matrices is that they provide a convenient notation for matrix multiplication: if a and b are matrices, then a*b is their matrix product. On the other hand, as … Read more

Obtain smallest value from array in Javascript?

The tersest expressive code to find the minimum value is probably rest parameters: Rest parameters are essentially a convenient shorthand for Function.prototype.apply when you don’t need to change the function’s context: This is also a great use case for Array.prototype.reduce: It may be tempting to pass Math.min directly to reduce, however the callback receives additional parameters: In this particular case it may … Read more

How to set axis range R

Without data, I tried to reproduce your plot error: Which gives the following plot: Changing your plot to: Might solve your problem. Edit It seems that the formula changes to factors and orders it from 1 to the number of items, so I’ll use your trick on the y axis to solve this.