matplotlib

How to plot a Python 3-dimensional level set?

≯℡__Kan透↙ 提交于 2021-01-27 08:58:51
问题 I have some trouble plotting the image which is in my head. I want to visualize the Kernel-trick with Support Vector Machines. So I made some two-dimensional data consisting of two circles (an inner and an outer circle) which should be separated by a hyperplane. Obviously this isn't possible in two dimensions - so I transformed them into 3D. Let n be the number of samples. Now I have an (n,3)-array (3 columns, n rows) X of data points and an (n,1)-array y with labels. Using sklearn I get the

How to plot a Python 3-dimensional level set?

主宰稳场 提交于 2021-01-27 08:58:09
问题 I have some trouble plotting the image which is in my head. I want to visualize the Kernel-trick with Support Vector Machines. So I made some two-dimensional data consisting of two circles (an inner and an outer circle) which should be separated by a hyperplane. Obviously this isn't possible in two dimensions - so I transformed them into 3D. Let n be the number of samples. Now I have an (n,3)-array (3 columns, n rows) X of data points and an (n,1)-array y with labels. Using sklearn I get the

How can I add a label to colorbar using ImageGrid?

我是研究僧i 提交于 2021-01-27 08:56:27
问题 In a previous question, colobar label matplotlib in ImageGrid, had a solution for adding a label to the colorbar, but this seems to be broken with the current version. Platforms I have tried: Mac w/ Canopy: python: 2.7 matplotlib: 1.4.3-6 Linux: python: 2.7 matplotlib: 1.3.1 Below is the code from the previous question, with some extra code for running in an iPython notebook: import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import AxesGrid def get_demo_image(): import numpy as np

Matplotlib in Jupyter results in variable “is not defined”

[亡魂溺海] 提交于 2021-01-27 08:31:59
问题 I'm having a strange issue using Jupyter to plot some simple data. There is a lot of nuance to my specific use-case, not the least of which is a Jupyter notebook connected to our cloud-based Spark cluster with a PySpark kernel. I can't, for the life of me, figure out why this simple code will not run without error. In reality I have to have the code set up like this, because instead of "x" and "y" I'm dealing with a data frame sourced from a Hive query - using the %sql magic and manipulating

How to plot a 3D histogram with matplotlib/mplot3d?

微笑、不失礼 提交于 2021-01-27 07:23:39
问题 I have three arrays and I am trying to make a 3D histogram. x = [1, 2, 3, 2, 5, 2, 6, 8, 6, 7] y = [10, 10, 20, 50, 20, 20, 30, 10, 40, 50, 60] z = [105, 25, 26, 74, 39, 85, 74, 153, 52, 98] Here's my attempt so far: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = plt.axes(projection='3d') binsOne = sorted(set(x)) binsTwo = sorted(set(y)) hist, xedges, yedges = np.histogram2d(x, y, bins=[binsOne, binsTwo]) xpos, ypos = np

matplotlib plotting multiple lines in 3D

試著忘記壹切 提交于 2021-01-27 07:10:19
问题 I am trying to plot multiple lines in a 3D plot using matplotlib. I have 6 datasets with x and y values. What I've tried so far was, to give each point in the data sets a z-value. So all points in data set 1 have z=1 all points of data set 2 have z=2 and so on. Then I exported them into three files. "X.txt" containing all x-values, "Y.txt" containing all y-values, same for "Z.txt". Here's the code so far: #!/usr/bin/python from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as

matplotlib plotting multiple lines in 3D

你。 提交于 2021-01-27 07:07:32
问题 I am trying to plot multiple lines in a 3D plot using matplotlib. I have 6 datasets with x and y values. What I've tried so far was, to give each point in the data sets a z-value. So all points in data set 1 have z=1 all points of data set 2 have z=2 and so on. Then I exported them into three files. "X.txt" containing all x-values, "Y.txt" containing all y-values, same for "Z.txt". Here's the code so far: #!/usr/bin/python from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as

How to use custom error bar in seaborn lineplot?

喜你入骨 提交于 2021-01-27 07:04:03
问题 I am using seaborn.lineplot to generate some time series plots. I have pre-compute a specific kind of error bars in two lists, e.g., upper=[1,2,3,4,5] lower=[0,1,2,3,4] . Is there a way I could customize the error bar here, instead of using the CI or Std error bars in lineplot ? 回答1: If you want error bands/bars other than the ones that seaborn.lineplot offers, you have to plot them yourself. Here are a couple examples of how to draw an error band and error bars in matplotlib and get plots

How to use custom error bar in seaborn lineplot?

一个人想着一个人 提交于 2021-01-27 07:03:12
问题 I am using seaborn.lineplot to generate some time series plots. I have pre-compute a specific kind of error bars in two lists, e.g., upper=[1,2,3,4,5] lower=[0,1,2,3,4] . Is there a way I could customize the error bar here, instead of using the CI or Std error bars in lineplot ? 回答1: If you want error bands/bars other than the ones that seaborn.lineplot offers, you have to plot them yourself. Here are a couple examples of how to draw an error band and error bars in matplotlib and get plots

unwanted blank subplots in matplotlib

大城市里の小女人 提交于 2021-01-27 06:49:43
问题 I am new to matplotlib and seaborn and is currently trying to practice the two libraries using the classic titanic dataset. This might be elementary, but I'm trying to plot two factorplots side by side by inputting the argument ax = matplotlib axis as shown in the code below: import matploblib.pyplot as plt import seaborn as sns %matplotlib inline fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4)) sns.factorplot(x='Pclass',data=titanic_df,kind='count',hue='Survived',ax=axis1) sns