Posts

Showing posts with the label matplotlib

Ordering and Formatting Dates on X-Axis in Seaborn Bar Plot

Image
Ordering and Formatting Dates on X-Axis in Seaborn Bar Plot This seems so simple, but for the life of me I can't figure it out. I am new to Python and Seaborn, and I am doing all this online at PythonAnywhere. All I am trying to do is create a simple barplot in seaborn, with dates ordered properly (that is, ascending from left to right), on the x-axis. When I try this: import matplotlib.pyplot as plt import matplotlib.dates as mdates import datetime import pandas as pd import seaborn as sns emp = pd.DataFrame([[32, "5/31/2018"], [3, "2/28/2018"], [40, "11/30/2017"], [50, "8/31/2017"], [51, "5/31/2017"]], columns=["jobs", "12monthsEnding"]) fig = plt.figure(figsize = (10,7)) sns.barplot(x = "12monthsEnding", y = "uniqueClientExits", data = emp, estimator = sum, ci = None) fig.autofmt_xdate() plt.show() I get this: Nice looking bar graph but with the dates ordered descending from ...

Bar plot with x and y axis

Image
Bar plot with x and y axis Now i am getting the bar chart as i attached above, kindly let me know why i am getting range in x-axis. Where is the mistake This is sample dataset. Plant Country Fault Level Type Fault Location Fault_loss 0 001 ESPP1 TH All Plant Internal PV Plant Incidents NaN 2.5 1 001 ESPP1 TH All Plant External Grid Forced Outage NaN 1.3 2 001 ESPP1 TH All Plant External Grid Forced Outage NaN 0.3 3 001 ESPP1 TH All Plant External Grid Forced Outage NaN 31.9 4 001 ESPP1 TH All Plant External Grid Forced Outage NaN 0.3 5 001 ESPP1 TH All Plant External Grid Forced Outage NaN 0.1 6 001 ESPP1 TH All Plant External Grid Forced Outage NaN 0.1 7 001 ESPP1 TH All Plant External Grid Forced Outage ...

How to add a subplot

Image
How to add a subplot How can you add a graph as a subplot . subplot I can plot a stand alone graph . But I would like to add this as a subplot . plot graph subplot import pandas as pd import matplotlib.pyplot as plt d = ({ 'A' : ['1','1','1','2','2','2','3','3','3','3'], 'B' : ['A','B','C','A','B','C','D','A','B','C'], 'C' : ['John','Carl','Carl','John','Lily','John','Lily','John','Carl','Carl'], 'D' : [1,2,3,4,5,6,7,8,9,10], 'E' : [0,2,4,6,5,6,7,8,9,10], }) df = pd.DataFrame(data=d) fig = plt.figure(figsize = (9,4)) def One_plot(ax,pid, fontsize=12): ax.set_title('One Plot', fontsize=10) ax.scatter(df['E'],df['D']) ax.grid(False) def Tw...

setting an array element with a sequence matplolib 3d

setting an array element with a sequence matplolib 3d I have the following strange problem. I am trying to do a 3d plot. That works ok. I wanted to put the projections on the surfaces of the plot. My code looks at the moment like this fig = plt.figure(figsize = (10,8)) ax = fig.add_subplot(111, projection='3d') ax.plot_trisurf(xarr, yarr, zarr, cmap=cm.coolwarm, linewidth=50) ax.set_xlabel('nMAE', fontsize = 14, linespacing = 1.5) ax.set_ylabel('nDIFF', fontsize = 14) ax.set_zlabel('nCounts', fontsize = 14, linespacing=1.5) cset = ax.contour(np.array(xx), np.array(yy), np.array(zz), zdir='z', offset=-100, cmap=cm.coolwarm) cset = ax.contour(xx, yy, np.array(zz), zdir='x', offset=-40, cmap=cm.coolwarm) cset = ax.contour(xx, yy, np.array(zz), zdir='y', offset=40, cmap=cm.coolwarm) plt.show() What is not working is the following line cset = ax.contour(np.array(xx), np.array(yy), np.array(zz), zdir='z', offse...

Can I visualize the outer box of 3D plot?

Image
Can I visualize the outer box of 3D plot? My current plot looks something like this now, image1 But I'd like to add outer boarders so that I can have a closed box. Like this, image2 I am currently using Python3.6, matplotlib.pyplot I know that MATLAB gives such options(these images are from MATLAB documentation), so I thought matplotlib may provide the same. But I have failed to find any documentations regarding this issue. Do I have such options to visualize the outer box, or should I use another package instead? 1 Answer 1 You may try the method set_frame_on from the class Axes on the current axes. set_frame_on Axes 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.