subplot

Plotly axis as exponential format

夙愿已清 提交于 2019-12-11 13:24:56
问题 This is a follow up on this question: SO Q The answer in the above question uses JavaScript code that turns an axis ticks into exponential. It works for a single axis on a single plot. When running it in a subplot() structure, it only works on the first plot when I apply it to the final plot. The modification I am looking for are these: 1: How to make it work on subplots. I tried calling JavaScript in the build of each subplot, but all plots came out without exponential then. 2: make it work

How to plot 2 subplots from different functions in the same window(figure)?

你。 提交于 2019-12-11 13:01:30
问题 for specific reasons I have two functions, each of them creates a plot in two different windows. Is it possible to unify this two plots in one window, without unifying the functions? thanks! edit: I have 2 involved functions and a database: function 1 in file1.py plots a 2d-line plot: plt.figure("TEST12") ax=plt.subplot(111) ax.plot(array[:,10]) In file2.py theres my other function, which plots a filled contour: plt.figure("TEST13") ax = plt.subplot(111) ax.contourf(x,y,data) plt.gca().set

matplotlib dynamic number of subplot

人走茶凉 提交于 2019-12-11 06:06:56
问题 I am trying to get a subplot using matplotlib , with number of subplots calculated in runtime (as pnum varies in the example below) pnum = len(args.m) f, (ax1, ax2) = plt.subplots(pnum, sharex=True, sharey=True) ax1.plot(x,ptp, "#757578",label="Total") ax2.fill_between(x,dxyp,facecolor="C0", label="$d_{xy}$") This example, obviously, only work, when pnum=2. So, I need to do some thing else. I have checked the accepted answer of this question, but this is plotting same thing in all the plots.

How can I plot four subplots with different colspans?

吃可爱长大的小学妹 提交于 2019-12-11 05:31:20
问题 I try to fit four images using matplotlib.pyplot like the following: | plot1 | plot2| | plot3 | | plot4 | Most examples I found cover three plots like these: ax1 = plt.subplot(221) ax2 = plt.subplot(222) ax3 = plt.subplot(212) And this plots the three plots successfully (However, I don't get how it is done for ax3 ). Now, I want to add the plot 4 to this arrangement. Whatever I tried, I couldn't succeed. Could you please guide me how can I achieve it? 回答1: You can use subplot2grid. It is

Matplotlib: Same height for subfigures

假装没事ソ 提交于 2019-12-11 03:08:43
问题 in the following example, how can I set both subfigures to the same height? #minimal example import matplotlib.pyplot as plt import numpy as np f, (ax1, ax2) = plt.subplots(1, 2) im = np.random.random((100,100)) ax1.imshow(im) ax1.set_xlim(0, im.shape[1]) ax1.set_ylim(0, im.shape[0]) x = np.arange(100) ax2.plot(x, x**2) 回答1: You can use matplotlib.gridspec : import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import numpy as np # Add subplots using gridspec instead of plt

matplotlib sharex with colorbar not working

ε祈祈猫儿з 提交于 2019-12-11 02:16:55
问题 I have 2 subplots- 1 scatter and one bar for which I would like a shared x axis. The scatter plot has a color bar. The sharex doesn't seem to work with this as the axis for the two plots do not coincide. My code: fig, (ax, ax2) = plt.subplots(2,1, gridspec_kw = {'height_ratios':[13,2]},figsize=(15,12), sharex=True) df_plotdata.plot(kind='scatter', ax=ax, x='index_cancer', y='index_g', s=df_plotdata['freq1']*50, c=df_plotdata['freq2'], cmap=cmap) df2.plot(ax=ax2, x='index_cancer', y='freq',

Plotting on multiple figures with subplots in a single loop

蓝咒 提交于 2019-12-11 01:16:02
问题 I'm plotting on two figures and each of these figures have multiple subplots. I need to do this inside a single loop. Here is what I do when I have only one figure: fig, ax = plt.subplots(nrows=6,ncols=6,figsize=(20, 20)) fig.subplots_adjust(hspace=.5,wspace=0.4) plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) for x in range(1,32): plt.subplot(6,6,x) plt.title('day='+str(x)) plt.scatter(x1,y1) plt.scatter(x2,y2) plt.colorbar().set_label('Distance

Getting ticks in figure with subplots

十年热恋 提交于 2019-12-10 23:38:13
问题 I have a complicated figure made in matplotlib with three subplots, two of which have twin axes. It works well except there are no tick marks in the figure and I can't figure out how to get them. Here is the code and figure: fig = plt.figure() gs = gridspec.GridSpec(3, 1) idx=0 n=len(d_10[idx]) fac=0.2 ax1=fig.add_subplot(gs[0,0]) ax1.errorbar(range(n),d_10[idx]["abs(Overlap)"][0:n],yerr=d_10[idx]["ErrOverlap"][0:n],ms=4,mew=0.7,marker="o",ls='none',elinewidth=0.7,capsize=3,fillstyle='none'

Subplot in existing R plot

给你一囗甜甜゛ 提交于 2019-12-10 21:57:21
问题 I have a plot as shown below. To this plot i would like to add a similar kind of line plot somewhere within the plot (bottomright or bottomleft). The command for the subplot i am using is plot( 1:121, sample(1:121),type='l' ) It plots right on the top of the first one. I need it as a small plot either at the bottomleft or bottomright. COuld someone help to do this in R? 回答1: op <- par(no.readonly = TRUE) set.seed(42) plot(rnorm(100), runif(100)) par(new=TRUE, oma=c(3,1,1,2)) layout(matrix(1:4

Matplotlib Subplot Animation with Basemap

元气小坏坏 提交于 2019-12-10 15:43:11
问题 I am trying to generate a four-panel animation of temperature change with time. Each of the four panels in the subplot should be an animated map; the difference between each panel being the data used. I have managed to generate the animation using one set of data (without subplots) with the following code: import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from mpl_toolkits.basemap import Basemap #dummy temperature data with 10 time-steps y=np.random