I am still unable to get separate maps plotted, but from what I understand, subplots is the way I should approach this problem, so hopefully I am on the right track. I've also tried following multiple examples of code using subplots for different uses. I have tried to make several adjustments based on the documentation provided here: When I run the above code, all of my data plots on to one map. Mean6 = fig.contour(lons,lats,day6,levels=60,extend='both',transform=fcst_crs)įig1 = plt.contour(mean1, colors = 'black')įig2 = plt.contour(mean2, colors = 'black')įig3 = plt.contour(mean3, colors = 'black')įig4 = plt.contour(mean4, colors = 'black')įig5 = plt.contour(mean5, colors = 'black')įig6 = plt.contour(mean6, colors = 'black') Mean5 = fig.contour(lons,lats,day5,levels=60,extend='both',transform=fcst_crs) Mean4 = fig.contour(lons,lats,day4,levels=60,extend='both',transform=fcst_crs) import matplotlib.pyplot as plt import numpy as np from import PdfPages fig,axplt.subplots(2,2,figsize(15,10)) xnp.linspace(-3,3) ax0,0.plot(x,x2) This is just to make an actual plot. Mean3 = fig.contour(lons,lats,da圓,levels=60,extend='both',transform=fcst_crs) This will save each subplot from the figure as a different page in a single pdf. Mean2 = fig.contour(lons,lats,day2,levels=60,extend='both',transform=fcst_crs) How can I make this code into a subplot-Thank you in advance, I am a newbie in python. When I add plt.subplots(2,1,2) for this figure it ends up separating this figure into a separate figure and the subplot is an empty figure. Mean1 = fig.contour(lons,lats,day1,levels=60,extend='both',transform=fcst_crs) I want to make this figure into one subplot out of 2 that I will have. #take mean of 500mb heights for the first 24 hoursĪx0 = plt.axes(projection=ccrs.PlateCarree())Īx0.set_extent(,ccrs.PlateCarree())Īx0.set_title('Mean 500mb Heights (dam)', fontsize=12) import matplotlib.pyplot as pltįrom import LongitudeFormatter, LatitudeFormatterįrom cartopy.util import add_cyclic_point The latter attempt to make it work is almost an exact copy of the code from 'Python for Data Analysis'.I am trying to plot separate maps for six different time steps of my data set. It seems that even if I print temp1 twice, the first subplot is blank for some reason. Temp2 = df.pivot_table(values='Loan_Status',index,aggfunc=lambda x: x.map().mean()) The code for temp1 and temp2 are as follows: temp1 = df.value_counts(ascending=True) I've also attempted to print it this way with similar results: fig, axes = plt.subplots(1, 2, figsize=(10, 8)) While writing this I read some of 'Python for Data Analysis' and tried some new code to no avail. I can not for the life of me figure out why this is the case. Unfortunately, it seems like the code I am using is only utilizing ONE of the subplots, and then producing the other plot on a new line. As I use the 'plot' command, the subplots should be utilized in the order they were generated.I specify that the figure will have two subplots, with the '121' and '122' specifying they will be horizontally adjacent to each other.My understanding of what is supposed to happen is: However, when I attempt this, I have been getting this no matter how much I jiggle around with things. This is supposed to produce the following: ![]() As part of following along, I'm running the following code: import matplotlib.pyplot as pltĪx1.set_title("Applicants by Credit_History")Īx2.set_ylabel('Probability of getting loan')Īx2.set_title("Probability of getting loan by credit history") I am currently working on some Vidhya articles.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |