Skip to content

Tag: python

Plotting in a non-blocking way with Matplotlib

I am having problems trying to make matplotlib plot a function without blocking execution. I have tried using show(block=False) as some people suggest, but all I get is a frozen window. If I simply call show(), the result is plotted properly but execution is blocked until the window is closed. From other thre…

Pandas dataframe.dot division method

I am trying to divide two series of different length to return the matrix product dataframe of them. I can multiply them using the dot method (from this answer): I’ve tried the div method, but this just fills the dataframe with NaNs: Likewise the standard division operator also returns the same result: …

ObsPy Plot Beachball in Time Series

I am trying to plot an ObsPy (or any python) seismic focal mechanism in time series. When using an integer/float series for x it works fine, but the time series fails here: The function xy2patch in the source code is trying to scale the time by a float value. Any ideas? Hack the source? Other packages? Thanks…

Removing pixels surrounded by white pixels OpenCV

I have a black and white image which has a lot of noise. I would like to remove only black pixels that are completely surrounded by white ones. I tried doing so with Filter2d, but I could not achieve it. Answer I’d use a convolution (again) 1: As you can see, the result array has changed all “blac…

tweepy error response status code 400

I’m trying to write a simple twitter bot using python and tweepy. The code is as follows: I get the following error: I would like some info on how to avoid this error Answer This may be a bug that emerged in the 3.2.0 release of Tweepy. See this issue opened on GitHub. In that issue, TylerGlaiel notes t…