matplotlib

python 1/x plot scale formatting, tick position

守給你的承諾、 提交于 2021-02-20 03:45:39
问题 I have plotted some data with Python and tried to change the ticks with FuncFormatter . Now I want to change the segmentation into round numbers. I also want minor ticks in the same formation, in my case it would be a 1/x segmentation. I want the scaling to spread. The pictures will help you to imagine my issue. import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as tick x = np.array([805.92055,978.82006,564.88627,813.70311,605.73361,263.27184,169.40317]) y = np.array(

Python Error: Using matplotlib: Truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

我与影子孤独终老i 提交于 2021-02-20 02:36:45
问题 So I am trying to plot a graph of 3 of my functions for a beam on one graph using the matplotlib module and am getting value errors when attempting to do so. The main bulk of code is: class beam(object): '''This class is models the deflection of a simply supported beam under multiple point loads, following Euler-Bernoulli theory and the principle of superposition ''' def __init__(self, E, I, L): '''The class costructor ''' self.E = E # Young's modulus of the beam in N/m^2 self.I = I # Second

Python Error: Using matplotlib: Truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

我们两清 提交于 2021-02-20 02:35:13
问题 So I am trying to plot a graph of 3 of my functions for a beam on one graph using the matplotlib module and am getting value errors when attempting to do so. The main bulk of code is: class beam(object): '''This class is models the deflection of a simply supported beam under multiple point loads, following Euler-Bernoulli theory and the principle of superposition ''' def __init__(self, E, I, L): '''The class costructor ''' self.E = E # Young's modulus of the beam in N/m^2 self.I = I # Second

Formatting X axis with dates format Matplotlib

佐手、 提交于 2021-02-19 08:35:08
问题 I have written code which plots the past seven day stock value for a user-determined stock market over time. The problem I have is that I want to format the x axis in a YYMMDD format. I also don't understand what 2.014041e7 means at the end of the x axis. Values for x are: 20140421.0, 20140417.0, 20140416.0, 20140415.0, 20140414.0, 20140411.0, 20140410.0 Values for y are: 531.17, 524.94, 519.01, 517.96, 521.68, 519.61, 523.48 My code is as follows: mini = min(y) maxi = max(y) minimum = mini -

Change default colorbar for 3D scatter plot with matplotlib

跟風遠走 提交于 2021-02-19 08:25:19
问题 I have 3d coordinates defining positions of points in my 3D scatter plot with a corresponding number of values who I want to create a colour scale for representing the range of values as such: from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') xs,ys,zs = np.random.random(50),np.random.random(50),np.random.random(50) values = np.random.random(50)*10 p = ax.scatter3D(xs, ys, zs=zs, c=values) cbar = fig.colorbar(p) cbar.cmap(plt.cm.Greys)

Multiple x labels on Pyplot

大城市里の小女人 提交于 2021-02-19 07:30:47
问题 Below is my code for a line graph. I would like another x label under the current one (so I can show the days of the week). import matplotlib.pyplot as plt import pandas as pd import seaborn as sns;sns.set() sns.set() data = pd.read_csv("123.csv") data['DAY']=["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"] plt.figure(figsize=(15,8)) plt.plot('DAY','SWST',data=data,linewidth=2,color="k"

show error bar in multi line plot using matplotlib

落花浮王杯 提交于 2021-02-19 06:14:53
问题 I've created a multi line plot using marplot lib, and now I want to show the min-max value for each parameter on X-axis. My code is below: import numpy as np import pandas as pd from pandas import DataFrame import matplotlib.pyplot as plt from matplotlib import pyplot as plt import seaborn as sns df = pd.DataFrame({'Time': ['D=0','D=2','D=5','D=X'], 'Latency': [74.92, 75.32, 79.64, 100], 'Delay': [18.2,80,82,84] }) plt.plot( 'Time', 'Latency', data=df, marker='s', color='black', markersize=4,

show error bar in multi line plot using matplotlib

让人想犯罪 __ 提交于 2021-02-19 06:13:44
问题 I've created a multi line plot using marplot lib, and now I want to show the min-max value for each parameter on X-axis. My code is below: import numpy as np import pandas as pd from pandas import DataFrame import matplotlib.pyplot as plt from matplotlib import pyplot as plt import seaborn as sns df = pd.DataFrame({'Time': ['D=0','D=2','D=5','D=X'], 'Latency': [74.92, 75.32, 79.64, 100], 'Delay': [18.2,80,82,84] }) plt.plot( 'Time', 'Latency', data=df, marker='s', color='black', markersize=4,

C++: matplotlibcpp.h and Python.h linker error

≯℡__Kan透↙ 提交于 2021-02-19 05:30:12
问题 I am finding trouble linking a library in C++. I am trying for the first time to use "matplotlibcpp.h". This is a library that uses "Python.h" My code is not using either of the libraries yet. It gives error just by including "matplotlibcpp". I am using python2.7 and Ubuntu 18.04 and am using Eclipse. The code does not run if I include: #include "matplotlibcpp.h" // programme runs if this is commented out. But I need it to add new features. #include "Python.h" I have added these paths in

C++: matplotlibcpp.h and Python.h linker error

混江龙づ霸主 提交于 2021-02-19 05:28:59
问题 I am finding trouble linking a library in C++. I am trying for the first time to use "matplotlibcpp.h". This is a library that uses "Python.h" My code is not using either of the libraries yet. It gives error just by including "matplotlibcpp". I am using python2.7 and Ubuntu 18.04 and am using Eclipse. The code does not run if I include: #include "matplotlibcpp.h" // programme runs if this is commented out. But I need it to add new features. #include "Python.h" I have added these paths in