Posts

Showing posts with the label matplotlib

matplotlib crosshair cursor in PyQt dialog does not show up

Image
Clash Royale CLAN TAG #URR8PPP matplotlib crosshair cursor in PyQt dialog does not show up I want to have a crosshair at the cursor in my matplotlib window. This works out in the example, given in the matplotlib gallery. But unfortunately, it does not work if I have the matplotlib widget in a Qt dialog window ( QDialog ). matplotlib QDialog This is my sample of code, where I want to instantiate the matplotlib.widgets.Cursor object, but nothing shows up. matplotlib.widgets.Cursor import sys from PyQt4 import QtGui from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas import matplotlib.pyplot as plt from matplotlib.widgets import Cursor class Window(QtGui.QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) self.figure = plt.figure(facecolor='white') self.canvas = FigureCanvas(self.figure) layout = QtGui.QVBoxLayout() layout.addWidget(self.canvas) self.setLayout(layout) ...

Trying to plot with more than one parameter using BaysianOptimization

Image
Clash Royale CLAN TAG #URR8PPP Trying to plot with more than one parameter using BaysianOptimization I am new to python and Bayesian Optimization. I'm using this example to find the maximum value of the "target" polynomial function. The example uses only one "x" parameter for the function and produces a plot that looks like this: . But I want to use a function with two "x" and "z" parameters. After adding a second "z" parameter, the code (below) appears to still calculate and identify the max correctly, but does not plot the results, and produces this error: ValueError: XA and XB must have the same number of columns (i.e. feature dimension.) I've been playing with the code and searching for days, but still haven't figured out why it's doing this. Does anyone know how to get this code to plot when using two parameters in the "target" function? I'm using Python 3.6.4 with Anaconda and Jupyter. Here is my code...

Invert y axis on actual data instead of just on the plot

Image
Clash Royale CLAN TAG #URR8PPP Invert y axis on actual data instead of just on the plot I have some locations of features that are represented in pixel coordinate space (ie. (0,0) is in the top left corner of the image, and the y axis increases downwards and the x axis increases rightwards). When I plot these locations in Matplotlib (which by default uses the positive x and positive y quadrant of a cartesian plane) I always run the command plt.gca().invert_yaxis() so that the locations of the features look right in the plot. However, I would like to apply this transformation to the image points themselves, not just in the visualization. Show your data. – John Zwinck 9 mins ago a = np.arange(9).reshape(3,3) …. np.flipud(a) …. is this what you mean? ...

How to plot column from a dataframe

Image
Clash Royale CLAN TAG #URR8PPP How to plot column from a dataframe I am trying to plot integer columns of dataframe. I am trying by following way for i in df: if df[i].dtypes == 'int64': df[i].plot.kde() But it is plotting all in the same graph. I am new to it and would like to know how can I do it? This answer may help your question :https://stackoverflow.com/questions/22483588/how-can-i-plot-separate-pandas-dataframes-as-subplots df.select_dtypes(include=["integer"]).columns.size calculates your axis size. – Ceyhun yesterday df.select_dtypes(include=["integer"]).columns.size DO you want one graph per time, subplots?.. – Joe yesterday ...

Creating a class to product subplots

Image
Clash Royale CLAN TAG #URR8PPP Creating a class to product subplots I was wondering about how to design a nice class in order to produce a matplotlib plot suitable for my purpose. The first thing that I want to obtain is a class that could be callable as follows, but I have no idea of how to design such a class. This is how I want to use it: fig,axs = MyClass(parameter...) How can I properly use this? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Python Pylab scatter plot error bars (the error on each point is unique)

Image
Clash Royale CLAN TAG #URR8PPP Python Pylab scatter plot error bars (the error on each point is unique) I am attempting a scatter plot of 2 arrays for which I have a third array containing the absolute error (error in y direction) on each point. I want the error bars to between (point a - error on a) and (point a + error on a). Is there a way of achieving this with pylab and if not any ideas on how else I could do it? 3 Answers 3 >>> import matplotlib.pyplot as plt >>> a = [1,3,5,7] >>> b = [11,-2,4,19] >>> plt.pyplot.scatter(a,b) >>> plt.scatter(a,b) <matplotlib.collections.PathCollection object at 0x00000000057E2CF8> >>> plt.show() >>> c = [1,3,2,1] >>> plt.errorbar(a,b,yerr=c, linestyle="None") <Container object of 3 artists> >>> plt.show() where a is your x data b is your y data c is your y err...

Tried to update matplotlib; lost it completely

Image
Clash Royale CLAN TAG #URR8PPP Tried to update matplotlib; lost it completely On my Mac OSX machine, I am unable to import mpl_toolkits with python2-7. I thought I would fix this by upgrading matplotib. I tried sudo pip install --U matplotlib It was a no-go with a very long error message that I will show at the end of this question. Then, on a lark, I tried dropping the sudo: pip install --U matplotlib It failed with error Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/kiwisolver.so' Consider using the `--user` option or check the permissions. What the heck? I think. I'll give sudo one more try. It fails with a new error: Found existing installation: six 1.4.1 Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Now here's real kicker: I can no longer import matplotli...

How to automatically set the scale for x-axis to be equal for all subplots in matplotlib?

Image
Clash Royale CLAN TAG #URR8PPP How to automatically set the scale for x-axis to be equal for all subplots in matplotlib? In this example: import numpy as np import matplotlib.pyplot as plt t1 = np.linspace(0, 1, 1000) t2 = np.linspace(0, 0.5, 1000) plt.figure(figsize=(10,5)) plt.subplot(121) plt.plot(t1, np.sin(t1 * np.pi)) plt.subplot(122) plt.plot(t2, np.sin(t2 * np.pi)) plt.show() How can I squeeze the size of the second plot so that the x-axis for both subplots would have the same scale? I am looking for a simple and automatic way to do this because I have more than 30 subplots and would want them all have the same x-axis scale. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.