category
stringclasses
107 values
title
stringlengths
15
179
question_link
stringlengths
59
147
question_body
stringlengths
53
33.8k
answer_html
stringlengths
0
28.8k
__index_level_0__
int64
0
1.58k
matplotlib
Secondary axis with twinx(): how to add to legend
https://stackoverflow.com/questions/5484922/secondary-axis-with-twinx-how-to-add-to-legend
<p>I have a plot with two y-axes, using <code>twinx()</code>. I also give labels to the lines, and want to show them with <code>legend()</code>, but I only succeed to get the labels of one axis in the legend:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from matplotlib import rc rc('mathtext', def...
<p>You can easily add a second legend by adding the line:</p> <pre><code>ax2.legend(loc=0) </code></pre> <p>You'll get this:</p> <p><img src="https://i.sstatic.net/DLZkF.png" alt="enter image description here"></p> <p>But if you want all labels on one legend then you should do something like this:</p> <pre><code>i...
1,034
matplotlib
How to set a single, main title above all the subplots
https://stackoverflow.com/questions/7066121/how-to-set-a-single-main-title-above-all-the-subplots
<p>I am using <code>pyplot</code>. I have 4 subplots. How to set a single, main title above all the subplots? <code>title()</code> sets it above the last subplot.</p>
<p>Use <a href="https://matplotlib.org/api/_as_gen/matplotlib.pyplot.suptitle.html?highlight=suptitle#matplotlib.pyplot.suptitle" rel="noreferrer"><code>pyplot.suptitle</code></a> or <a href="https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html?highlight=suptitle#matplotlib.figure.Figure.suptitle" rel="nore...
1,035
matplotlib
Plot two histograms on single chart
https://stackoverflow.com/questions/6871201/plot-two-histograms-on-single-chart
<p>I created a histogram plot using data from a file and no problem. Now I wanted to superpose data from another file in the same histogram, so I do something like this</p> <pre><code>n,bins,patchs = ax.hist(mydata1,100) n,bins,patchs = ax.hist(mydata2,100) </code></pre> <p>but the problem is that for each interval, ...
<p>Here you have a working example:</p> <pre><code>import random import numpy from matplotlib import pyplot x = [random.gauss(3,1) for _ in range(400)] y = [random.gauss(4,2) for _ in range(400)] bins = numpy.linspace(-10, 10, 100) pyplot.hist(x, bins, alpha=0.5, label='x') pyplot.hist(y, bins, alpha=0.5, label='y'...
1,036
matplotlib
How to make inline plots in Jupyter Notebook larger?
https://stackoverflow.com/questions/36367986/how-to-make-inline-plots-in-jupyter-notebook-larger
<p>I have made my plots inline on my Ipython Notebook with "<code>%matplotlib inline</code>."</p> <p>Now, the plot appears. However, it is very small. Is there a way to make it appear larger using either notebook settings or plot settings?</p> <p><a href="https://i.sstatic.net/TiQum.png"><img src="https://i.sstatic...
<p>Yes, play with <code>figuresize</code> and <code>dpi</code> like so (before you call your subplot):</p> <pre><code>fig=plt.figure(figsize=(12,8), dpi= 100, facecolor='w', edgecolor='k') </code></pre> <p>As @tacaswell and @Hagne pointed out, you can also change the defaults if it's not a one-off:</p> <pre><code>plt.r...
1,037
matplotlib
Set markers for individual points on a line
https://stackoverflow.com/questions/8409095/set-markers-for-individual-points-on-a-line
<p>I have used Matplotlib to plot lines on a figure. Now I would now like to set the style, specifically the marker, for individual points on the line. How do I do this?</p> <p>To clarify my question, I want to be able to set the style for individual markers on a line, not every marker on said line.</p>
<p>Specify the keyword args <code>linestyle</code> and/or <code>marker</code> in your call to <code>plot</code>.</p> <p>For example, using a dashed line and blue circle markers:</p> <pre><code>plt.plot(range(10), linestyle='--', marker='o', color='b', label='line with marker') plt.legend() </code></pre> <p>A shortcut c...
1,038
matplotlib
Scatter plot with different text at each data point
https://stackoverflow.com/questions/14432557/scatter-plot-with-different-text-at-each-data-point
<p>I am trying to make a scatter plot and annotate data points with different numbers from a list. So, for example, I want to plot <code>y</code> vs <code>x</code> and annotate with corresponding numbers from <code>n</code>.</p> <pre><code>y = [2.56422, 3.77284, 3.52623, 3.51468, 3.02199] x = [0.15, 0.3, 0.45, 0.6, 0.7...
<p>I'm not aware of any plotting method which takes arrays or lists but you could use <code>annotate()</code> while iterating over the values in <code>n</code>.</p> <pre><code>import matplotlib.pyplot as plt x = [0.15, 0.3, 0.45, 0.6, 0.75] y = [2.56422, 3.77284, 3.52623, 3.51468, 3.02199] n = [58, 651, 393, 203, 123] ...
1,039
matplotlib
Named colors in matplotlib
https://stackoverflow.com/questions/22408237/named-colors-in-matplotlib
<p>What named colors are available in matplotlib for use in plots? I can find a list on the matplotlib documentation that claims that these are the only names:</p> <pre><code>b: blue g: green r: red c: cyan m: magenta y: yellow k: black w: white </code></pre> <p>However, I've found that these colors can also be used...
<p>I constantly forget the names of the colors I want to use and keep coming back to this question =)</p> <p>The previous answers are great, but I find it a bit difficult to get an overview of the available colors from the posted image. I prefer the colors to be grouped with similar colors, so I slightly tweaked the <...
1,040
matplotlib
Reduce left and right margins in matplotlib plot
https://stackoverflow.com/questions/4042192/reduce-left-and-right-margins-in-matplotlib-plot
<p>I'm struggling to deal with my plot margins in matplotlib. I've used the code below to produce my chart:</p> <pre><code>plt.imshow(g) c = plt.colorbar() c.set_label("Number of Slabs") plt.savefig("OutputToUse.png") </code></pre> <p>However, I get an output figure with lots of white space on either side of the plot...
<p>One way to automatically do this is the <code>bbox_inches='tight'</code> kwarg to <a href="https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.savefig" rel="noreferrer"><code>plt.savefig</code></a>.</p> <p>E.g.</p> <pre><code>import matplotlib.pyplot as plt import numpy as np ...
1,041
matplotlib
Seaborn plots not showing up
https://stackoverflow.com/questions/26597116/seaborn-plots-not-showing-up
<p>I'm sure I'm forgetting something very simple, but I cannot get certain plots to work with Seaborn. </p> <p>If I do:</p> <pre><code>import seaborn as sns </code></pre> <p>Then any plots that I create as usual with matplotlib get the Seaborn styling (with the grey grid in the background).</p> <p>However, if I try...
<p>Plots created using seaborn need to be displayed like ordinary matplotlib plots. This can be done using the</p> <pre><code>plt.show() </code></pre> <p>function from matplotlib.</p> <p>Originally I posted the solution to use the already imported matplotlib object from seaborn (<code>sns.plt.show()</code>) however thi...
1,042
matplotlib
Generating a PNG with matplotlib when DISPLAY is undefined
https://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined
<p>I am trying to use networkx with Python. When I run this program it get this error. Is there anything missing?</p> <pre><code>#!/usr/bin/env python import networkx as nx import matplotlib import matplotlib.pyplot import matplotlib.pyplot as plt G=nx.Graph() G.add_node(1) G.add_nodes_from([2,3,4,5,6,7,8,9,10]) #nx...
<p>The main problem is that (on your system) matplotlib chooses an x-using backend by default. I just had the same problem on one of my servers. The solution for me was to add the following code in a place that gets read <em>before</em> any other pylab/matplotlib/<strong>pyplot</strong> import:</p> <pre><code>import m...
1,043
matplotlib
Common xlabel/ylabel for matplotlib subplots
https://stackoverflow.com/questions/16150819/common-xlabel-ylabel-for-matplotlib-subplots
<p>I have the following plot:</p> <pre><code>fig,ax = plt.subplots(5,2,sharex=True,sharey=True,figsize=fig_size) </code></pre> <p>and now I would like to give this plot common x-axis labels and y-axis labels. With "common", I mean that there should be one big x-axis label below the whole grid of subplots, and one big...
<p>This looks like what you actually want. It applies the same approach of <a href="https://stackoverflow.com/a/6981055/3753826">this answer</a> to your specific case:</p> <pre><code>import matplotlib.pyplot as plt fig, ax = plt.subplots(nrows=3, ncols=3, sharex=True, sharey=True, figsize=(6, 6)) fig.text(0.5, 0.04, ...
1,044
matplotlib
How to remove frame from a figure
https://stackoverflow.com/questions/14908576/how-to-remove-frame-from-a-figure
<p>To remove frame in figure, I write</p> <pre><code>frameon=False </code></pre> <p>works perfect with <code>pyplot.figure</code>, but with <code>matplotlib.Figure</code> it only removes the gray background, the frame stays. Also, I only want the lines to show, and all the rest of figure be transparent.</p> <p>with pyp...
<p>First off, if you're using <code>savefig</code>, be aware that it will override the figure's background color when saving unless you specify otherwise (e.g. <code>fig.savefig('blah.png', transparent=True)</code>).</p> <p>However, to remove the axes' and figure's background on-screen, you'll need to set both <code>a...
1,045
matplotlib
ImportError: No module named matplotlib.pyplot
https://stackoverflow.com/questions/18176591/importerror-no-module-named-matplotlib-pyplot
<p>I am currently practicing matplotlib. This is the first example I practice.</p> <pre><code>#!/usr/bin/python import matplotlib.pyplot as plt radius = [1.0, 2.0, 3.0, 4.0] area = [3.14159, 12.56636, 28.27431, 50.26544] plt.plot(radius, area) plt.show() </code></pre> <p>When I run this script with <code>python ./pl...
<p>You have two pythons installed on your machine, one is the standard python that comes with Mac OSX and the second is the one you installed with ports (this is the one that has <code>matplotlib</code> installed in its library, the one that comes with macosx does not).</p> <pre><code>/usr/bin/python </code></pre> <p...
1,046
matplotlib
Matplotlib different size subplots
https://stackoverflow.com/questions/10388462/matplotlib-different-size-subplots
<p>I need to add two subplots to a figure. One subplot needs to be about three times as wide as the second (same height). I accomplished this using <code>GridSpec</code> and the <code>colspan</code> argument but I would like to do this using <code>figure</code> so I can save to PDF. I can adjust the first figure using ...
<ul> <li>As of <code>matplotlib 3.6.0</code>, <code>width_ratios</code> and <code>height_ratios</code> can now be passed directly as keyword arguments to <a href="https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.subplots" rel="noreferrer"><code>plt.subplots</code></a> and <a href="https://matp...
1,047
matplotlib
Plot a horizontal line on a given plot
https://stackoverflow.com/questions/33382619/plot-a-horizontal-line-on-a-given-plot
<p>How do I add a horizontal line to an existing plot?</p>
<p>You are correct, I think the <code>[0,len(xs)]</code> is throwing you off. You'll want to reuse the original x-axis variable <code>xs</code> and plot that with another numpy array of the same length that has your variable in it.</p> <pre><code>annual = np.arange(1,21,1) l = np.array(value_list) # a list with 20 val...
1,048
matplotlib
Is there a way to detach matplotlib plots so that the computation can continue?
https://stackoverflow.com/questions/458209/is-there-a-way-to-detach-matplotlib-plots-so-that-the-computation-can-continue
<p>After these instructions in the Python interpreter one gets a window with a plot:</p> <pre><code>from matplotlib.pyplot import * plot([1,2,3]) show() # other code </code></pre> <p>Unfortunately, I don't know how to continue to interactively explore the figure created by <code>show()</code> while the program does f...
<p>Use <code>matplotlib</code>'s calls that won't block:</p> <p>Using <code>draw()</code>:</p> <pre><code>from matplotlib.pyplot import plot, draw, show plot([1,2,3]) draw() print('continue computation') # at the end call show to ensure window won't close. show() </code></pre> <p>Using interactive mode:</p> <pre><code...
1,049
matplotlib
tight_layout() doesn&#39;t take into account figure suptitle
https://stackoverflow.com/questions/8248467/tight-layout-doesnt-take-into-account-figure-suptitle
<p>If I add a subtitle to my matplotlib figure it gets overlaid by the subplot's titles. Does anybody know how to easily take care of that? I tried the <code>tight_layout()</code> function, but it only makes things worse.</p> <p>Example:</p> <pre class="lang-python prettyprint-override"><code>import numpy as np impor...
<p>You can adjust the subplot geometry in the very <code>tight_layout</code> call as follows:</p> <pre><code>fig.tight_layout(rect=[0, 0.03, 1, 0.95]) </code></pre> <p>As it's stated in the documentation (<a href="https://matplotlib.org/stable/users/explain/axes/tight_layout_guide.html" rel="noreferrer">https://matplot...
1,050
matplotlib
How to have one colorbar for all subplots
https://stackoverflow.com/questions/13784201/how-to-have-one-colorbar-for-all-subplots
<p>I've spent entirely too long researching how to get two subplots to share the same y-axis with a single colorbar shared between the two in Matplotlib. </p> <p>What was happening was that when I called the <code>colorbar()</code> function in either <code>subplot1</code> or <code>subplot2</code>, it would autoscale t...
<p>Just place the colorbar in its own axis and use <code>subplots_adjust</code> to make room for it.</p> <p>As a quick example:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=2, ncols=2) for ax in axes.flat: im = ax.imshow(np.random.random((10,10)), vmin=0, vmax=...
1,051
matplotlib
plot a circle with Matplotlib.pyplot
https://stackoverflow.com/questions/9215658/plot-a-circle-with-matplotlib-pyplot
<p>surprisingly I didn't find a straight-forward description on how to draw a circle with matplotlib.pyplot (please no pylab) taking as input center (x,y) and radius r. I tried some variants of this:</p> <pre><code>import matplotlib.pyplot as plt circle=plt.Circle((0,0),2) # here must be something like circle.plot() o...
<p>You need to add it to an axes. A <a href="https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.patches.Circle.html" rel="noreferrer"><code>Circle</code></a> is a subclass of an <a href="https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.patches.Patch.html" rel="noreferrer"><code>Patch</code></a>, and an <code>axes</...
1,052
matplotlib
Adding a y-axis label to secondary y-axis in matplotlib
https://stackoverflow.com/questions/14762181/adding-a-y-axis-label-to-secondary-y-axis-in-matplotlib
<p>I can add a y label to the left y-axis using <code>plt.ylabel</code>, but how can I add it to the secondary y-axis?</p> <pre><code>table = sql.read_frame(query,connection) table[0].plot(color=colors[0],ylim=(0,100)) table[1].plot(secondary_y=True,color=colors[1]) plt.ylabel('$') </code></pre>
<p>The best way is to interact with the <code>axes</code> object directly</p> <pre><code>import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 10, 0.1) y1 = 0.05 * x**2 y2 = -1 *y1 fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot(x, y1, 'g-') ax2.plot(x, y2, 'b-') ax1.set_xlabel('X data') ax1.set_...
1,053
matplotlib
Savefig outputs blank image
https://stackoverflow.com/questions/9012487/savefig-outputs-blank-image
<p>I am trying to save plots I make using matplotlib; however, the images are saving blank.</p> <p>Here is my code:</p> <pre><code>plt.subplot(121) plt.imshow(dataStack, cmap=mpl.cm.bone) plt.subplot(122) y = copy.deepcopy(tumorStack) y = np.ma.masked_where(y == 0, y) plt.imshow(dataStack, cmap=mpl.cm.bone) plt.ims...
<p>First, what happens when <code>T0 is not None</code>? I would test that, then I would adjust the values I pass to <code>plt.subplot()</code>; maybe try values 131, 132, and 133, or values that depend whether or not <code>T0</code> exists.</p> <p>Second, after <code>plt.show()</code> is called, a new figure is creat...
1,054
matplotlib
Removing white space around a saved image
https://stackoverflow.com/questions/11837979/removing-white-space-around-a-saved-image
<p>I need to take an image and save it after some process. The figure looks fine when I display it, but after saving the figure, I got some white space around the saved image. I have tried the <code>'tight'</code> option for <code>savefig</code> method, did not work either. The code:</p> <pre><code>import matplotlib.im...
<p>I cannot claim I know exactly why or how my &ldquo;solution&rdquo; works, but this is what I had to do when I wanted to plot the outline of a couple of aerofoil sections &mdash; without white margins &mdash; to a PDF file. (Note that I used matplotlib inside an IPython notebook, with the -pylab flag.)</p> <pre><co...
1,055
matplotlib
Moving matplotlib legend outside of the axis makes it cutoff by the figure box
https://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box
<p>I'm familiar with the following questions:</p> <p><a href="https://stackoverflow.com/questions/8971834/matplotlib-savefig-with-a-legend-outside-the-plot">Matplotlib savefig with a legend outside the plot</a></p> <p><a href="https://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot">How to p...
<p><em>[EDIT - 25th Feb 2025] My day job is no longer Python, so I'm not following the recent matplotlib developments. Please read all the newer answers here as there look to be some excellent modern suggestions compared to this solution from the ancient history of 2012.</em></p> <p>Sorry EMS, but I actually just got a...
1,056
matplotlib
How do I plot in real-time in a while loop?
https://stackoverflow.com/questions/11874767/how-do-i-plot-in-real-time-in-a-while-loop
<p>I am trying to plot some data from a camera in real time using OpenCV. However, the real-time plotting (using matplotlib) doesn't seem to be working.</p> <p>I've isolated the problem into this simple example:</p> <pre><code>fig = plt.figure() plt.axis([0, 1000, 0, 1]) i = 0 x = list() y = list() while i &lt; 100...
<p>Here's the working version of the code in question (requires at least version Matplotlib 1.1.0 from 2011-11-14):</p> <pre><code>import numpy as np import matplotlib.pyplot as plt plt.axis([0, 10, 0, 1]) for i in range(10): y = np.random.random() plt.scatter(i, y) plt.pause(0.05) plt.show() </code></pr...
1,057
matplotlib
How to draw a rectangle on image
https://stackoverflow.com/questions/37435369/how-to-draw-a-rectangle-on-image
<p>How to draw a rectangle on an image, like this: <a href="https://i.sstatic.net/KWG46.jpg" rel="noreferrer"><img src="https://i.sstatic.net/KWG46.jpg" alt="enter image description here" /></a></p> <pre><code>import matplotlib.pyplot as plt from PIL import Image import numpy as np im = np.array(Image.open('dog.png'), ...
<p>You can add a <a href="https://matplotlib.org/api/_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle" rel="noreferrer"><code>Rectangle</code></a> patch to the matplotlib Axes.</p> <p>For example (using the image from the tutorial <a href="https://matplotlib.org/stable/tutorials/introductory/image...
1,058
matplotlib
Plot correlation matrix using pandas
https://stackoverflow.com/questions/29432629/plot-correlation-matrix-using-pandas
<p>I have a data set with huge number of features, so analysing the correlation matrix has become very difficult. I want to plot a correlation matrix which we get using <code>dataframe.corr()</code> function from pandas library. Is there any built-in function provided by the pandas library to plot this matrix?</p>
<p>You can use <a href="http://matplotlib.org/examples/pylab_examples/matshow.html" rel="noreferrer"><code>pyplot.matshow()</code></a> from <code>matplotlib</code>:</p> <pre><code>import matplotlib.pyplot as plt plt.matshow(dataframe.corr()) plt.show() </code></pre> <hr /> <p>Edit:</p> <p>In the comments was a reques...
1,059
matplotlib
matplotlib Legend Markers Only Once
https://stackoverflow.com/questions/6146778/matplotlib-legend-markers-only-once
<p>I often plot a point on a matplotlib plot with:</p> <pre><code>x = 10 y = 100 plot(x, y, "k*", label="Global Optimum") legend() </code></pre> <p>However, this causes the legend to put a star in the legend twice, such that it looks like:</p> <pre><code>* * Global Optimum </code></pre> <p>when I really want it to ...
<p>This should work:</p> <pre><code>legend(numpoints=1) </code></pre> <p>BTW, if you add the line</p> <pre><code>legend.numpoints : 1 # the number of points in the legend line </code></pre> <p>to your matplotlibrc file, then this will be the new default.</p> <p>[See also scatterpoints, depending on your p...
1,060
matplotlib
How can I remove the top and right axis?
https://stackoverflow.com/questions/925024/how-can-i-remove-the-top-and-right-axis
<p>Instead of the default "boxed" axis style I want to have only the left and bottom axis, i.e.:</p> <pre><code>+------+ | | | | | | ---&gt; | | | | +------+ +------- </code></pre> <p>This should be easy, but I can't find the necessary options in the docs.</p>
<p>This is the suggested Matplotlib 3 solution from the official website <a href="http://matplotlib.org/examples/ticks_and_spines/spines_demo.html" rel="noreferrer">HERE</a>:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2*np.pi, 100) y = np.sin(x) ax = plt.subplot(111) ax.plot(...
1,061
matplotlib
Display image as grayscale
https://stackoverflow.com/questions/3823752/display-image-as-grayscale
<p>I'm trying to display a grayscale image using <code>matplotlib.pyplot.imshow()</code>. My problem is that the grayscale image is displayed as a colormap. I need it to be grayscale because I want to draw on top of the image with color.</p> <p>I read in the image and convert to grayscale using PIL's <code>Image.open...
<p>The following code will load an image from a file <code>image.png</code> and will display it as grayscale.</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from PIL import Image fname = 'image.png' image = Image.open(fname).convert("L") arr = np.asarray(image) plt.imshow(arr, cmap='gray', vmin=0, ...
1,062
matplotlib
Getting individual colors from a color map in matplotlib
https://stackoverflow.com/questions/25408393/getting-individual-colors-from-a-color-map-in-matplotlib
<p>If you have a <a href="https://matplotlib.org/stable/tutorials/colors/colormaps.html" rel="noreferrer">Colormap</a> <code>cmap</code>, for example:</p> <pre><code>cmap = matplotlib.cm.get_cmap('Spectral') </code></pre> <p>How can you get a particular colour out of it between 0 and 1, where 0 is the first colour in t...
<p>You can do this with the code below, and the code in your question was actually very close to what you needed, all you have to do is call the <code>cmap</code> object you have.</p> <pre><code>import matplotlib cmap = matplotlib.cm.get_cmap('Spectral') rgba = cmap(0.5) print(rgba) # (0.99807766255210428, 0.9992310...
1,063
matplotlib
Modify tick label text
https://stackoverflow.com/questions/11244514/modify-tick-label-text
<p>I want to make some modifications to a few selected tick labels in a plot.</p> <p>For example, if I do:</p> <pre><code>label = axes.yaxis.get_major_ticks()[2].label label.set_fontsize(size) label.set_rotation('vertical') </code></pre> <p>the font size and the orientation of the tick label is changed.</p> <p>However,...
<p>Caveat: Unless the ticklabels are already set to a string (as is usually the case in e.g. a boxplot), this will not work with any version of matplotlib newer than <code>1.1.0</code>. If you're working from the current github master, this won't work. I'm not sure what the problem is yet... It may be an unintended ...
1,064
matplotlib
warning about too many open figures
https://stackoverflow.com/questions/21884271/warning-about-too-many-open-figures
<p>In a script where I create many figures with <code>fix, ax = plt.subplots(...)</code>, I get the warning <em>RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (<code>matplotlib.pyplot.figure</code>) are retained until explicitly closed and may consume too much memory...
<p>Use <code>.clf</code> or <code>.cla</code> on your figure object instead of creating a <em>new</em> figure. From <a href="https://stackoverflow.com/a/8228808/249341">@DavidZwicker</a></p> <p>Assuming you have imported <code>pyplot</code> as</p> <pre><code>import matplotlib.pyplot as plt </code></pre> <p><a href="...
1,065
matplotlib
How to put individual tags for a matplotlib scatter plot?
https://stackoverflow.com/questions/5147112/how-to-put-individual-tags-for-a-matplotlib-scatter-plot
<p>I am trying to do a scatter plot in matplotlib and I couldn't find a way to add tags to the points. For example:</p> <pre><code>scatter1=plt.scatter(data1["x"], data1["y"], marker="o", c="blue", facecolors="white", edgecolors="blue") </code></pre> <p>I...
<p>Perhaps use <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.annotate">plt.annotate</a>:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt N = 10 data = np.random.random((N, 4)) labels = ['point{0}'.format(i) for i in range(N)] plt.subplots_adjust(bottom = 0.1) plt.scatter( ...
1,066
matplotlib
Specifying and saving a figure with exact size in pixels
https://stackoverflow.com/questions/13714454/specifying-and-saving-a-figure-with-exact-size-in-pixels
<p>Say I have an image of size 3841 x 7195 pixels. I would like to save the contents of the figure to disk, resulting in an image of the <strong>exact size</strong> I specify in pixels.</p> <p>No axis, no titles. Just the image. I don't personally care about DPIs, as I only want to specify the size the image takes in ...
<p>Matplotlib doesn't work with pixels directly, but rather physical sizes and DPI. If you want to display a figure with a certain pixel size, you need to know the DPI of your monitor. For example <a href="http://www.infobyip.com/detectmonitordpi.php" rel="noreferrer">this link</a> will detect that for you.</p> <p>If y...
1,067
matplotlib
How do I make a single legend for many subplots?
https://stackoverflow.com/questions/9834452/how-do-i-make-a-single-legend-for-many-subplots
<p>I am plotting the same type of information, but for different countries, with multiple subplots with Matplotlib. That is, I have nine plots on a 3x3 grid, all with the same for lines (of course, different values per line).</p> <p>However, I have not figured out how to put a single legend (since all nine subplots hav...
<p>There is also a nice function <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.get_legend_handles_labels.html" rel="nofollow noreferrer"><code>get_legend_handles_labels()</code></a> you can call on the last axis (if you iterate over them) that would collect everything you need from <code>label...
1,068
matplotlib
Plot yerr/xerr as shaded region rather than error bars
https://stackoverflow.com/questions/12957582/plot-yerr-xerr-as-shaded-region-rather-than-error-bars
<p>In matplotlib, how do I plot error as a shaded region rather than error bars?</p> <p>For example:</p> <p><a href="https://i.sstatic.net/skJ5O.png" rel="noreferrer"><img src="https://i.sstatic.net/skJ5O.png" alt="enter image description here"></a></p> <p>rather than</p> <p><a href="https://i.sstatic.net/CV5i6.gif...
<p>Ignoring the smooth interpolation between points in your example graph (that would require doing some manual interpolation, or just have a higher resolution of your data), you can use <a href="https://matplotlib.org/3.1.3/api/_as_gen/matplotlib.pyplot.fill_between.html" rel="noreferrer"><code>pyplot.fill_between()<...
1,069
matplotlib
Rotate label text in seaborn
https://stackoverflow.com/questions/26540035/rotate-label-text-in-seaborn
<p>I have a simple factorplot</p> <pre><code>import seaborn as sns g = sns.factorplot("name", "miss_ratio", "policy", dodge=.2, linestyles=["none", "none", "none", "none"], data=df[df["level"] == 2]) </code></pre> <p><img src="https://i.sstatic.net/gg7aD.png" alt="enter image description here"></p> <p>The probl...
<p>You can rotate tick labels with the <code>tick_params</code> method on matplotlib <code>Axes</code> objects. To provide a specific example:</p> <pre><code>ax.tick_params(axis='x', rotation=90) </code></pre>
1,070
matplotlib
Date ticks and rotation
https://stackoverflow.com/questions/11264521/date-ticks-and-rotation
<p>I am having an issue trying to get my date ticks rotated in matplotlib. A small sample program is below. If I try to rotate the ticks at the end, the ticks do not get rotated. If I try to rotate the ticks as shown under the comment 'crashes', then matplot lib crashes. </p> <p>This only happens if the x-values are d...
<p>If you prefer a non-object-oriented approach, move <code>plt.xticks(rotation=70)</code> to right <em>before</em> the two <code>avail_plot</code> calls, eg</p> <pre><code>plt.xticks(rotation=70) avail_plot(axs[0], dates, s1, 'testing', 'green') avail_plot(axs[1], dates, s1, 'testing2', 'red') </code></pre> <p>This ...
1,071
matplotlib
How to plot a high resolution graph
https://stackoverflow.com/questions/39870642/how-to-plot-a-high-resolution-graph
<p>I've used matplotlib for plotting some experimental results (discussed it in here: <a href="https://stackoverflow.com/questions/39676294/looping-over-files-and-plotting-python/" title="Looping over files and plotting &#40;Python&#41;">Looping over files and plotting</a>. However, saving the picture by clicking right...
<p>You can use <a href="https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.savefig" rel="nofollow noreferrer"><code>savefig()</code></a> to export to an image file:</p> <pre><code>plt.savefig('filename.png') </code></pre> <p>In addition, you can specify the <code>dpi</code> argume...
1,072
matplotlib
How do I draw a grid onto a plot in Python?
https://stackoverflow.com/questions/8209568/how-do-i-draw-a-grid-onto-a-plot-in-python
<p>I just finished writing code to make a plot using <a href="https://en.wikipedia.org/wiki/Matplotlib#Comparison_with_MATLAB" rel="noreferrer">pylab</a> in Python and now I would like to superimpose a grid of 10x10 onto the scatter plot. How do I do that?</p> <p>My current code is the following:</p> <pre class="lang-p...
<p>You want to use <code>pyplot.grid</code>:</p> <pre><code>x = numpy.arange(0, 1, 0.05) y = numpy.power(x, 2) fig = plt.figure() ax = fig.gca() ax.set_xticks(numpy.arange(0, 1, 0.1)) ax.set_yticks(numpy.arange(0, 1., 0.1)) plt.scatter(x, y) plt.grid() plt.show() </code></pre> <p><code>ax.xaxis.grid</code> and <code...
1,073
matplotlib
How to set the subplot axis range
https://stackoverflow.com/questions/2849286/how-to-set-the-subplot-axis-range
<p>How can I set the y axis range of the second subplot to e.g. [0,1000] ? The FFT plot of my data (a column in a text file) results in a (inf.?) spike so that the actual data is not visible.</p> <pre class="lang-py prettyprint-override"><code>pylab.ylim([0,1000]) </code></pre> <p>has no effect, unfortunately. This is ...
<p>You have <a href="https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.ylim.html" rel="noreferrer"><code>pylab.ylim</code></a>:</p> <pre><code>pylab.ylim([0,1000]) </code></pre> <p>Note: The command has to be executed after the plot!</p> <p><strong>Update 2021</strong><br /> Since <a href="https://matplotlib.o...
1,074
matplotlib
_tkinter.TclError: no display name and no $DISPLAY environment variable
https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable
<p>I am running a simple python script in the server:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np x = np.random.randn(60) y = np.random.randn(60) plt.scatter(x, y, s=20) out_png = 'path/to/store/out_file.png' plt.savefig(out_png, dpi=150) </code></pre> <p>I try to use the command <code>python...
<p>Matplotlib chooses Xwindows backend by default. You need to set matplotlib to not use the Xwindows backend. </p> <p>Add this code to the start of your script (<strong>before importing pyplot</strong>) and try again:</p> <pre><code>import matplotlib matplotlib.use('Agg') </code></pre> <p>Or add to <code>.config/m...
1,075
matplotlib
Plotting in a non-blocking way with Matplotlib
https://stackoverflow.com/questions/28269157/plotting-in-a-non-blocking-way-with-matplotlib
<p>I am having problems trying to make matplotlib plot a function without blocking execution.</p> <p>I have tried using <code>show(block=False)</code> as some people suggest, but all I get is a frozen window. If I simply call <code>show()</code>, the result is plotted properly but execution is blocked until the window ...
<p>I spent a long time looking for solutions, and found <a href="https://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib">this answer</a>.</p> <p>It looks like, in order to get what you (and I) want, you need the combination of <code>plt.ion()</code>, <code>plt.show()</code> (not ...
1,076
matplotlib
Generating matplotlib graphs without a running X server
https://stackoverflow.com/questions/4931376/generating-matplotlib-graphs-without-a-running-x-server
<p>Matplotlib seems to require the $DISPLAY environment variable which means a running X server.<br>Some web hosting services do not allow a running X server session.<br>Is there a way to generate graphs using matplotlib without a running X server?</p> <pre><code>[username@hostname ~]$ python2.6 Python 2.6.5 (r265:790...
<p>@Neil's answer is one (perfectly valid!) way of doing it, but you can also <a href="http://matplotlib.sourceforge.net/faq/howto_faq.html#matplotlib-in-a-web-application-server" rel="noreferrer">simply call <code>matplotlib.use('Agg')</code> <em>before</em> importing <code>matplotlib.pyplot</code></a>, and then conti...
1,077
matplotlib
Setting different color for each series in scatter plot
https://stackoverflow.com/questions/12236566/setting-different-color-for-each-series-in-scatter-plot
<p>Suppose I have three data sets:</p> <pre><code>X = [1,2,3,4] Y1 = [4,8,12,16] Y2 = [1,4,9,16] </code></pre> <p>I can scatter plot this:</p> <pre><code>from matplotlib import pyplot as plt plt.scatter(X,Y1,color='red') plt.scatter(X,Y2,color='blue') plt.show() </code></pre> <p>How can I do this with 10 sets? </p>...
<p>I don't know what you mean by 'manually'. You can choose a colourmap and make a colour array easily enough:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm x = np.arange(10) ys = [i+x+(i*x)**2 for i in range(10)] colors = cm.rainbow(np.linspace(0, 1, len(ys))) for y, c...
1,078
matplotlib
Matplotlib transparent line plots
https://stackoverflow.com/questions/4320021/matplotlib-transparent-line-plots
<p>I am plotting two similar trajectories in matplotlib and I'd like to plot each of the lines with partial transparency so that the red (plotted second) doesn't obscure the blue.</p> <p><img src="https://i.sstatic.net/O3V1B.png" alt="alt text"></p> <p><strong>EDIT</strong>: Here's the image with transparent lines.</...
<p>Plain and simple:</p> <pre><code>plt.plot(x, y, 'r-', alpha=0.7) </code></pre> <p>(I know I add nothing new, but the straightforward answer should be visible).</p>
1,079
matplotlib
Add x and y labels to a pandas plot
https://stackoverflow.com/questions/21487329/add-x-and-y-labels-to-a-pandas-plot
<p>Suppose I have the following code that plots something very simple using pandas:</p> <pre><code>import pandas as pd values = [[1, 2], [2, 5]] df2 = pd.DataFrame(values, columns=['Type A', 'Type B'], index=['Index 1', 'Index 2']) df2.plot(lw=2, colormap='jet', marker='.', markersize=10, ...
<p>In Pandas <em>version 1.10</em> you can use parameters <code>xlabel</code> and <code>ylabel</code> in the method <code>plot</code>:</p> <pre><code>df.plot(xlabel='X Label', ylabel='Y Label', title='Plot Title') </code></pre> <p><a href="https://i.sstatic.net/zPRPM.png" rel="noreferrer"><img src="https://i.sstatic.ne...
1,080
matplotlib
How to get different colored lines for different plots in a single figure
https://stackoverflow.com/questions/4805048/how-to-get-different-colored-lines-for-different-plots-in-a-single-figure
<p>I am using <code>matplotlib</code> to create the plots. I have to identify each plot with a different color which should be automatically generated by Python.</p> <p>Can you please give me a method to put different colors for different plots in the same figure? </p>
<p>Matplotlib does this by default.</p> <p>E.g.:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np x = np.arange(10) plt.plot(x, x) plt.plot(x, 2 * x) plt.plot(x, 3 * x) plt.plot(x, 4 * x) plt.show() </code></pre> <p><img src="https://i.sstatic.net/TGKN1m.png" alt="Basic plot demonstrating color cy...
1,081
matplotlib
Plotting a 2D heatmap
https://stackoverflow.com/questions/33282368/plotting-a-2d-heatmap
<p>Using Matplotlib, I want to plot a 2D heat map. My data is an n-by-n Numpy array, each with a value between 0 and 1. So for the (i, j) element of this array, I want to plot a square at the (i, j) coordinate in my heat map, whose color is proportional to the element's value in the array.</p> <p>How can I do this?</p...
<p>The <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html" rel="noreferrer"><code>imshow()</code></a> function with parameters <code>interpolation='nearest'</code> and <code>cmap='hot'</code> should do what you want.</p> <p>Please review the <code>interpolation</code> parameter details, an...
1,082
matplotlib
Calling pylab.savefig without display in ipython
https://stackoverflow.com/questions/15713279/calling-pylab-savefig-without-display-in-ipython
<p>I need to create a figure in a file without displaying it within IPython notebook. I am not clear on the interaction between <code>IPython</code> and <code>matplotlib.pylab</code> in this regard. But, when I call <code>pylab.savefig("test.png")</code> the current figure get's displayed in addition to being saved in ...
<p>This is a matplotlib question, and you can get around this by using a backend that doesn't display to the user, e.g. 'Agg':</p> <pre><code>import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.savefig('/tmp/test.png') </code></pre> <p><strong>EDIT:</strong> If you don't wan...
1,083
matplotlib
Plt.show shows full graph but savefig is cropping the image
https://stackoverflow.com/questions/37427362/plt-show-shows-full-graph-but-savefig-is-cropping-the-image
<p>My code is succesfully saving images to file, but it is cropping important details from the right hand side. <a href="https://stackoverflow.com/questions/6774086/why-is-my-xlabel-cut-off-in-my-matplotlib-plot">Answers</a> exist for fixing this problem when it arises for <code>plt.show</code>, but it is the <code>sav...
<p>You may try </p> <pre><code>plt.savefig('X:/' + newName + '.png', bbox_inches='tight') </code></pre> <p>Or you may define figure size like</p> <pre><code>fig = plt.figure(figsize=(9, 11)) ... plt.savefig(filename, bbox_inches = 'tight') </code></pre>
1,084
matplotlib
Get default line color cycle
https://stackoverflow.com/questions/42086276/get-default-line-color-cycle
<p>I noticed when you plot that the first line is blue, then orange, then green, and so on.</p> <p>Is there some way to access this list of colors? I've seen a million posts on how to change the color cycle or access the iterator, but not on how to just get the list of colors that matplotlib cycles through by default....
<p>In matplotlib versions &gt;= 1.5, you can print the <code>rcParam</code> called <code>axes.prop_cycle</code>:</p> <pre><code>print(plt.rcParams['axes.prop_cycle'].by_key()['color']) # [u'#1f77b4', u'#ff7f0e', u'#2ca02c', u'#d62728', u'#9467bd', u'#8c564b', u'#e377c2', u'#7f7f7f', u'#bcbd22', u'#17becf'] </code></pr...
1,085
matplotlib
Aligning rotated xticklabels with their respective xticks
https://stackoverflow.com/questions/14852821/aligning-rotated-xticklabels-with-their-respective-xticks
<p>Check the x axis of the figure below. How can I move the labels a bit to the left so that they align with their respective ticks?</p> <p>I'm rotating the labels using:</p> <pre><code>ax.set_xticks(xlabels_positions) ax.set_xticklabels(xlabels, rotation=45) </code></pre> <p>But, as you can see, the rotation is cen...
<p>You can set the horizontal alignment of ticklabels, see the example below. If you imagine a rectangular box around the rotated label, which side of the rectangle do you want to be aligned with the tickpoint?</p> <p>Given your description, you want: ha='right'</p> <pre><code>n=5 x = np.arange(n) y = np.sin(np.lins...
1,086
matplotlib
matplotlib error - no module named tkinter
https://stackoverflow.com/questions/36327134/matplotlib-error-no-module-named-tkinter
<p>I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code:</p> <pre><code>from matplotlib import pyplot </code></pre> <p>I get the following error:</p> <pre><code>ImportError: No module named 'tkinter' </code></pre> <p>I know that in python 2.x it was called Tkinter, but that is n...
<h3>For Linux</h3> <p>Debian based distros:</p> <pre><code>sudo apt-get install python3-tk </code></pre> <p>RPM based distros:</p> <pre><code>sudo yum install python3-tkinter </code></pre> <h3>For windows:</h3> <p>For Windows, I think the problem is you didn't install complete Python package. Since Tkinter should be sh...
1,087
matplotlib
What is the difference between drawing plots using plot, axes or figure in matplotlib?
https://stackoverflow.com/questions/37970424/what-is-the-difference-between-drawing-plots-using-plot-axes-or-figure-in-matpl
<p>I'm kind of confused what is going at the backend when I draw plots in matplotlib, tbh, I'm not clear with the hierarchy of plot, axes and figure. I read the documentation and it was helpful but I'm still confused...</p> <p>The below code draws the same plot in three different ways - </p> <pre><code>#creating the ...
<p><strong>Method 1</strong></p> <pre><code>plt.plot(x, y) </code></pre> <p>This lets you plot just one figure with (x,y) coordinates. If you just want to get one graphic, you can use this way.</p> <p><strong>Method 2</strong></p> <pre><code>ax = plt.subplot() ax.plot(x, y) </code></pre> <p>This lets you plot one ...
1,088
matplotlib
vertical &amp; horizontal lines in matplotlib
https://stackoverflow.com/questions/16930328/vertical-horizontal-lines-in-matplotlib
<p>I do not quite understand why I am unable to create horizontal and vertical lines at specified limits. I would like to bound the data by this box. However, the sides do not seem to comply with my instructions. Why is this? </p> <pre><code># CREATING A BOUNDING BOX # BOTTOM HORIZONTAL plt.axhline(y=.4, xmin=0.25, xm...
<p>The pyplot functions you are calling, <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.axhline"><code>axhline()</code></a> and <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.axvline"><code>axvline()</code></a> draw lines that span a portion of the axis range, regardless of c...
1,089
matplotlib
Remove or adapt border of frame of legend using matplotlib
https://stackoverflow.com/questions/25540259/remove-or-adapt-border-of-frame-of-legend-using-matplotlib
<p>When plotting a plot using matplotlib:</p> <ol> <li>How to remove the box of the legend? </li> <li>How to change the color of the border of the legend box?</li> <li>How to remove only the border of the box of the legend?</li> </ol>
<p>When plotting a plot using matplotlib:</p> <p>How to remove the box of the legend?</p> <pre><code>plt.legend(frameon=False) </code></pre> <p>How to change the color of the border of the legend box?</p> <pre><code>leg = plt.legend() leg.get_frame().set_edgecolor('b') </code></pre> <p>How to remove only the border of ...
1,090
matplotlib
How to set xlim and ylim for a subplot
https://stackoverflow.com/questions/15858192/how-to-set-xlim-and-ylim-for-a-subplot
<p>I would like to limit the X and Y axis in matplotlib for a specific subplot. The subplot figure itself doesn't have any axis property. I want for example to change only the limits for the second plot:</p> <pre><code>import matplotlib.pyplot as plt fig=plt.subplot(131) plt.scatter([1,2],[3,4]) fig=plt.subplot(132) pl...
<p>You should use the OO interface to matplotlib, rather than the state machine interface. Almost all of the <code>plt.*</code> function are thin wrappers that basically do <code>gca().*</code>.</p> <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.subplot" rel="noreferrer"><code>plt.subplot</co...
1,091
matplotlib
How to plot normal distribution
https://stackoverflow.com/questions/10138085/how-to-plot-normal-distribution
<p>Given a mean and a variance is there a simple function call which will plot a normal distribution?</p>
<pre><code>import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats import math mu = 0 variance = 1 sigma = math.sqrt(variance) x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100) plt.plot(x, stats.norm.pdf(x, mu, sigma)) plt.show() </code></pre> <p><img src="https://i.sstatic.net/IvOTE.png" alt="g...
1,092
matplotlib
How to update a plot in matplotlib
https://stackoverflow.com/questions/4098131/how-to-update-a-plot-in-matplotlib
<p>I'm having issues with redrawing the figure here. I allow the user to specify the units in the time scale (x-axis) and then I recalculate and call this function <code>plots()</code>. I want the plot to simply update, not append another plot to the figure.</p> <pre><code>def plots(): global vlgaBuffSorted cn...
<p>You essentially have two options:</p> <ol> <li><p>Do exactly what you're currently doing, but call <code>graph1.clear()</code> and <code>graph2.clear()</code> before replotting the data. This is the slowest, but most simplest and most robust option.</p></li> <li><p>Instead of replotting, you can just update the da...
1,093
matplotlib
How to set common axes labels for subplots
https://stackoverflow.com/questions/6963035/how-to-set-common-axes-labels-for-subplots
<p>I have the following plot:</p> <pre><code>import matplotlib.pyplot as plt fig2 = plt.figure() ax3 = fig2.add_subplot(2,1,1) ax4 = fig2.add_subplot(2,1,2) ax4.loglog(x1, y1) ax3.loglog(x2, y2) ax3.set_ylabel('hello') </code></pre> <p>I want to create axes labels and titles that span on both subplots. For example, s...
<p>You can create a big subplot that covers the two subplots and then set the common labels.</p> <pre class="lang-python prettyprint-override"><code>import random import matplotlib.pyplot as plt x = range(1, 101) y1 = [random.randint(1, 100) for _ in range(len(x))] y2 = [random.randint(1, 100) for _ in range(len(x))]...
1,094
matplotlib
How to remove gaps between subplots
https://stackoverflow.com/questions/20057260/how-to-remove-gaps-between-subplots
<p>The code below produces gaps between the subplots. How do I remove the gaps between the subplots and make the image a tight grid?</p> <p><a href="https://i.sstatic.net/uBn4j.png" rel="noreferrer"><img src="https://i.sstatic.net/uBn4j.png" alt="enter image description here"></a></p> <pre><code>import matplotlib.py...
<p>You can use <a href="http://matplotlib.org/api/gridspec_api.html" rel="noreferrer">gridspec</a> to control the spacing between axes. There's more <a href="http://matplotlib.org/users/gridspec.html" rel="noreferrer">information</a> here. </p> <pre><code>import matplotlib.pyplot as plt import matplotlib.gridspec as g...
1,095
matplotlib
How to convert a NumPy array to PIL image applying matplotlib colormap
https://stackoverflow.com/questions/10965417/how-to-convert-a-numpy-array-to-pil-image-applying-matplotlib-colormap
<p>I want to take a NumPy 2D array which represents a grayscale image, and convert it to an RGB PIL image while applying some of the matplotlib colormaps.</p> <p>I can get a reasonable PNG output by using the <code>pyplot.figure.figimage</code> command:</p> <pre><code>dpi = 100.0 w, h = myarray.shape[1]/dpi, myarray.sh...
<p>Quite a busy one-liner, but here it is:</p> <ol> <li>First ensure your NumPy array, <code>myarray</code>, is normalised with the max value at <code>1.0</code>.</li> <li>Apply the colormap directly to <code>myarray</code>.</li> <li>Rescale to the <code>0-255</code> range.</li> <li>Convert to integers, using <code>np...
1,096
matplotlib
Set Matplotlib colorbar size to match graph
https://stackoverflow.com/questions/18195758/set-matplotlib-colorbar-size-to-match-graph
<p>I cannot get the <code>colorbar</code> on <code>imshow</code> graphs like this one to be the same height as the graph, short of using Photoshop after the fact. How do I get the heights to match? <img src="https://i.sstatic.net/EXLiY.png" alt="Example of the colorbar size mismatch" /></p>
<p>You can do this easily with a matplotlib <a href="http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axesdivider" rel="noreferrer">AxisDivider</a>.</p> <p>The example from the linked page also works without using subplots:</p> <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as ...
1,097
matplotlib
How do I tell matplotlib that I am done with a plot?
https://stackoverflow.com/questions/741877/how-do-i-tell-matplotlib-that-i-am-done-with-a-plot
<p>The following code plots to two <a href="http://en.wikipedia.org/wiki/PostScript" rel="noreferrer">PostScript</a> (.ps) files, but the second one contains both lines.</p> <pre><code>import matplotlib import matplotlib.pyplot as plt import matplotlib.mlab as mlab plt.subplot(111) x = [1,10] y = [30, 1000] plt.loglo...
<p>You can use <code>figure</code> to create a new plot, for example, or use <code>close</code> after the first plot.</p>
1,098
matplotlib
How to set &#39;auto&#39; for upper limit, but keep a fixed lower limit
https://stackoverflow.com/questions/11744990/how-to-set-auto-for-upper-limit-but-keep-a-fixed-lower-limit
<p>I want to set the upper limit of the y-axis to 'auto', but I want to keep the lower limit of the y-axis to always be zero. I tried 'auto' and 'autorange', but those don't seem to work.</p> <p>Here is my code:</p> <pre><code>import matplotlib.pyplot as plt def plot(results_plt,title,filename): ################...
<p>You can pass just <code>left</code> or <code>right</code> to <code>set_xlim</code>:</p> <pre><code>plt.gca().set_xlim(left=0) </code></pre> <p>For the y axis, use <code>bottom</code> or <code>top</code>:</p> <pre><code>plt.gca().set_ylim(bottom=0) </code></pre> <p>Important note: &quot;you must use the functions AFT...
1,099
fine-tuning
Code-first vs Model/Database-first
https://stackoverflow.com/questions/5446316/code-first-vs-model-database-first
<p><strong>What are the pros &amp; cons of using Entity Framework 4.1 Code-first over Model/Database-first with EDMX diagram?</strong></p> <p>I'm trying to fully understand all the approaches to building data access layer using EF 4.1. I'm using Repository pattern and <code>IoC</code>.</p> <p>I know I can use code-fi...
<p>I think the differences are:</p> <p><strong>Code first</strong></p> <ul> <li>Very popular because hardcore programmers don't like any kind of designers and defining mapping in EDMX xml is too complex.</li> <li>Full control over the code (no autogenerated code which is hard to modify).</li> <li>General expectation ...
1,100
fine-tuning
LMM Fine Tuning - Supervised Fine Tuning Trainer (SFTTrainer) vs transformers Trainer
https://stackoverflow.com/questions/76461859/lmm-fine-tuning-supervised-fine-tuning-trainer-sfttrainer-vs-transformers-tr
<p>When should one opt for the Supervised Fine Tuning Trainer (SFTTrainer) instead of the regular Transformers Trainer when it comes to instruction fine-tuning for Language Models (LLMs)? From what I gather, the regular Transformers Trainer typically refers to unsupervised fine-tuning, often utilized for tasks such as ...
<p>I would suggest going for SFT trainer for faster training time and comparable outputs with efficient memory usage and simpler interface over Trainer.</p>
1,101
fine-tuning
Fine Tuning Blenderbot
https://stackoverflow.com/questions/72774975/fine-tuning-blenderbot
<p>I have been trying to fine-tune a conversational model of HuggingFace: Blendebot. I have tried the conventional method given on the official hugging face website which asks us to do it using the trainer.train() method. I also tried it using the .compile() method. I have tried fine-tuning using PyTorch as well as Ten...
<p>Here is a link I am using to fine-tune the blenderbot model.</p> <p>Fine-tuning methods: <a href="https://huggingface.co/docs/transformers/training" rel="nofollow noreferrer">https://huggingface.co/docs/transformers/training</a></p> <p>Blenderbot: <a href="https://huggingface.co/docs/transformers/model_doc/blenderbo...
1,102
fine-tuning
Fine tuning vs Retraining
https://stackoverflow.com/questions/45134834/fine-tuning-vs-retraining
<p>So I am learning how to use Tensorflow to fine tune the Inception-v3 model for a custom dataset.</p> <p>I found two tutorials related to this. One was about "<a href="https://www.tensorflow.org/tutorials/image_retraining" rel="noreferrer">How to Retrain Inception's Final Layer for New Categories</a>" and the other ...
<p>Usually in the ML literature we call fine tuning the process of:</p> <ol> <li>Keep a trained model. Model = feature extractor layers + classification layers</li> <li>Remove the classification layers</li> <li>Attach new classification layer</li> <li>Retrain the whole model end-to-end.</li> </ol> <p>This allow to st...
1,103
fine-tuning
Fine-tuning Glove Embeddings
https://stackoverflow.com/questions/50909726/fine-tuning-glove-embeddings
<p>Has anyone tried to fine-tune <strong>Glove embeddings</strong> on a domain-specific corpus?<br> <strong>Fine-tuning word2vec</strong> embeddings has proven very efficient for me in a various NLP tasks, but I am wondering whether generating a cooccurrence matrix on my domain-specific corpus, and training glove embed...
<p>I myself am trying to do the exact same thing. You can try <a href="https://github.com/ashutoshsingh0223/mittens" rel="nofollow noreferrer">mittens</a>.</p> <p>They have succesfully built a framework for it. Christopher D. Manning(co-author of GloVe) is associated with it.</p>
1,104
fine-tuning
BERT fine tuning
https://stackoverflow.com/questions/60418179/bert-fine-tuning
<p>I'm trying to create my model for question answering based on BERT und can't understand what is the meaning of fine tuning. Do I understand it right, that it is like adaption for specific domain? And if I want to use it with Wikipedia corpora, I just need to integrate unchanged pre-trained model in my network?</p>
<p>Fine tuning is adopting (refining) the pre-trained BERT model to two things:</p> <ol> <li>Domain</li> <li>Task (e.g. classification, entity extraction, etc.).</li> </ol> <p>You can use pre-trained models as-is at first and if the performance is sufficient, fine tuning for your use case may not be needed.</p>
1,105
fine-tuning
Fine Tuning of GoogLeNet Model
https://stackoverflow.com/questions/36841158/fine-tuning-of-googlenet-model
<p>I trained GoogLeNet model from scratch. But it didn't give me the promising results.<br> As an alternative, I would like to do fine tuning of GoogLeNet model on my dataset. Does anyone know what are the steps should I follow? </p>
<p>Assuming you are trying to do image classification. These should be the steps for finetuning a model:</p> <h3>1. Classification layer</h3> <p>The original <a href="https://github.com/BVLC/caffe/blob/master/models/bvlc_googlenet/train_val.prototxt" rel="noreferrer">classification layer <code>&quot;loss3/classifier&qu...
1,106
fine-tuning
Fine tuning vbscript
https://stackoverflow.com/questions/45689296/fine-tuning-vbscript
<p>I am writing a VBScript to pass back the date/time value (especially before 2:00 AM to get last day value). Is there any fine tuning instead of pass the value to another batch and use the Batch1 to call vbscript and then the batch2 (created in vbscript)? Thanks a lot</p> <pre><code>dim dateMonth, dateDay, dateYear,...
<p>I'm not sure if you want to run a batch script directly from VBScript, but in case that option is available, you don't need to write to generate a file at all - you can pass in the date and other info using command-line parameters.</p> <p>In the example below, I simplified your date code and then passed some fields...
1,107
fine-tuning
Fine-Tuning InceptionV3
https://stackoverflow.com/questions/62210883/fine-tuning-inceptionv3
<p>I want to fine-tuning Inception V3 for recognize the UC Merced Land Use Dataset. It contains 21 classes,with 100 images for each class. Manually I have split the Datataset in 5 fold, for each fold and for each class I have 60 images for training 20 for validation and 20 for Testing. Example: In the first fold for ea...
<p>There are few that may improve the classification accuracy:</p> <ol> <li><p>Use EfficientNet with noisy_student weights. There are less number of parameters to train. It gives better accuracy due to the scalable architecture it has.</p></li> <li><p>You can use test time augmentation. In your test data generator, do...
1,108
fine-tuning
How to fine tuning again of a bert fined tuned model
https://stackoverflow.com/questions/67318099/how-to-fine-tuning-again-of-a-bert-fined-tuned-model
<p>I did a fine tuning bert model for text classification using ktrain. Again i want to do fine tuning this model on another text classification data. How i can do?</p>
<p>See <a href="https://github.com/amaiya/ktrain/blob/master/FAQ.md#how-do-i-resume-training-from-a-saved-checkpoint" rel="nofollow noreferrer">this FAQ entry</a> on resuming training/fine-tuning.</p>
1,109
fine-tuning
Fine Tuning Stable Diffusion
https://stackoverflow.com/questions/73916442/fine-tuning-stable-diffusion
<p>I'm trying to use the fine tuning method for stable diffusion to generate AI art ths is the google colab link if required <a href="https://colab.research.google.com/drive/1yGiI2TYkFMuETm4Rh5bh3-k6yY1C38w0?usp=sharing#scrollTo=60jVYSk0BGC8&amp;uniqifier=3" rel="nofollow noreferrer">https://colab.research.google.com/d...
<p>There are a few issues with the code that need to be fixed. First, the download_image function uses the image.open method to open the image, but it should use the Image.open method instead. This is a typo that needs to be corrected.</p> <p>Second, the image_grid function is not defined in the code, so calling it wil...
1,110
fine-tuning
SpaCy fine-tuning GPU
https://stackoverflow.com/questions/78364403/spacy-fine-tuning-gpu
<p>I train a text classifier with spaCy and classy classification. But the model does not use gpu during training, fine-tuning is very long</p> <p>GPU info</p> <pre><code>$ nvidia-smi Mon Apr 22 09:41:13 2024 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI ...
1,111
fine-tuning
VGG16 fine tuning
https://stackoverflow.com/questions/58939250/vgg16-fine-tuning
<p>I'm trying to fine tune VGG16. But sometimes I got a validation accuracy that is constant, sometimes it is fixed to 0.0 and sometimes it is fixed to 1.0 and it is the same also on the test accuracy. It also happened that the training is constant.</p> <p>Those are some examples:</p> <p>Adam, bs: 64, lr: 0.001</p> <pr...
<p>Training accuracy increases and validation accuracy fluctuates are very obvious: the model is trying to learn how to &quot;memorize&quot; the training set, so we have validation set to prevent it from overfitting.</p> <p>Also seeing from the result, your model seems to learn so low. Try tuning the hyperparameters.</...
1,112
fine-tuning
Why 8bit quantized fine tuning of a model occupy more memory than just original model fine tuning?
https://stackoverflow.com/questions/78869197/why-8bit-quantized-fine-tuning-of-a-model-occupy-more-memory-than-just-original
<p>I trying to fine tune Mistral model for 5 epochs. It shows it take 72 hours with 8 bit quantized fine tuning but 48 hours with just original mode fine tuning. Also memory footprint is higher for 8bit quantized fine tuning. Below is the code where I am loading model for 8 bit quantization.</p> <pre><code>bnb_config =...
1,113
fine-tuning
Fine-tuning BERT sentence transformer model
https://stackoverflow.com/questions/69562624/fine-tuning-bert-sentence-transformer-model
<p>I am using a pre-trained BERT sentence transformer model, as described here <a href="https://www.sbert.net/docs/training/overview.html" rel="noreferrer">https://www.sbert.net/docs/training/overview.html</a> , to get embeddings for sentences.</p> <p>I want to fine-tune these pre-trained embeddings, and I am following...
<p>That actually depend on your requirement. If you have a lot of computational resources and you want to get a perfect sentence representation then you should finetune all the layers.(Which was done in the original sentence bert model)</p> <p>But if you are a student and want to create an almost good sentence represen...
1,114
fine-tuning
RRD fine tuning
https://stackoverflow.com/questions/19658887/rrd-fine-tuning
<p>I have used RRD few months back , for my large application where is in I was running around 5k RRD update from my application resulting in huge I?O at my box.</p> <p>I tried many things to improve the performance , but IO and corresponding load just forced me to move to flat files .</p> <p>Are there any guide lines...
<p>you must usa a) recent rrdtool (1.4.8) and b) make sure there is sufficient ram on the box so that the hot blocks of all rrds can be cached ... if you do testing, you should see that performance drops drastically as soon as you are over the cache limit. 10k/minute should be no problem at all.</p>
1,115
fine-tuning
Inception V3 fine tuning
https://stackoverflow.com/questions/48085257/inception-v3-fine-tuning
<p>I am not from cs background and I am trying to create a classifier in which I feed images containing disease and images without disease. I was trying to do fine tuning using inception v3 for this. Unfortunately all the examples for fine tuning are done for vgg-16 and they stop by saying inception v3 is trained simil...
<p>You seem to have multiple unrelated questions, but pretty much all of them are already answered in stackoverflow. I'll try to compile some information to give you some direction:</p> <blockquote> <p>i feed images containing disease and images without disease [...] Everyone tells me to truncate the final softmax l...
1,116
fine-tuning
Tensorflow fine tuning tutorial without Bazel
https://stackoverflow.com/questions/45071647/tensorflow-fine-tuning-tutorial-without-bazel
<p>I am using the Google Research tutorial for fine tuning the Inception model. </p> <p><a href="https://github.com/tensorflow/models/tree/master/inception/README.md#how-to-fine-tune-a-pre-trained-model-on-a-new-task" rel="nofollow noreferrer">The tutorial can be found here</a></p> <p>The tutorial uses Bazel.</p> <p...
<p>Yes you can.Just check <a href="https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/?utm_campaign=chrome_series_machinelearning_063016&amp;utm_source=gdev&amp;utm_medium=yt-desc#4." rel="nofollow noreferrer">this</a>.In the section 5.</p>
1,117
fine-tuning
OpenAI GPT-3 API: Fine tune a fine tuned model?
https://stackoverflow.com/questions/72758187/openai-gpt-3-api-fine-tune-a-fine-tuned-model
<p>The OpenAI documentation for the <code>model</code> attribute in the fine-tune API states a bit confusingly:</p> <blockquote> <p><strong>model</strong></p> <p>The name of the base model to fine-tune. You can select one of &quot;ada&quot;, &quot;babbage&quot;, &quot;curie&quot;, &quot;davinci&quot;, or a fine-tuned m...
<p><strong>UPDATE</strong></p> <p>It looks like fine-tuning a fine-tuned model is not supported anymore, as stated in the official <a href="https://platform.openai.com/docs/guides/fine-tuning/can-i-continue-fine-tuning-a-model-that-has-already-been-fine-tuned" rel="nofollow noreferrer">OpenAI documentation</a>:</p> <bl...
1,118
fine-tuning
Keras VGG16 fine tuning
https://stackoverflow.com/questions/43386463/keras-vgg16-fine-tuning
<p>There is an example of VGG16 fine-tuning on <a href="https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html" rel="noreferrer">keras blog</a>, but I can't reproduce it. </p> <p>More precisely, here is code used to init VGG16 without top layer and to freeze all blocks except t...
<p>I think that the weights described by the vgg net do not fit your model and the error stems from this. Anyways there is a way better way to do this using the network itself as described in (<a href="https://keras.io/applications/#vgg16" rel="nofollow noreferrer">https://keras.io/applications/#vgg16</a>).</p> <p>You...
1,119
fine-tuning
How does Fine-tuning Word Embeddings work?
https://stackoverflow.com/questions/40345607/how-does-fine-tuning-word-embeddings-work
<p>I've been reading some NLP with Deep Learning papers and found Fine-tuning seems to be a simple but yet confusing concept. There's been the same question asked <a href="https://stackoverflow.com/questions/40098450/hows-the-input-word2vec-get-fine-tuned-when-training-cnn/40098823#40098823">here</a> but still not quit...
<p>Yes, if you feed the embedding vector as your input, you can't fine-tune the embeddings (at least easily). However, all the frameworks provide some sort of an <code>EmbeddingLayer</code> that takes as input an integer that is the class ordinal of the word/character/other input token, and performs a embedding lookup....
1,120
fine-tuning
Fine tuning resnet18 for cifar10
https://stackoverflow.com/questions/73799136/fine-tuning-resnet18-for-cifar10
<p>I just want fine tuning ResNet18 on cifar10 datasets. so I just want to change the last linear layer from 1000 to 10. I tried use <code>children</code> function to get the previous layers</p> <pre class="lang-py prettyprint-override"><code>ResModel = resnet18(weights=ResNet18_Weights) model = nn.Sequential( *lis...
<p>The difference between stacking all layers into a single <code>nn.Sequential</code> and overriding only the last layer is the <code>forward</code> function:<br /> Your <code>ResModel</code> is of type <code>torchvision.models.ResNet</code>, while your <code>model</code> is a simple <code>nn.Sequential</code>. The <c...
1,121
fine-tuning
Wor2vec fine-tuning
https://stackoverflow.com/questions/56166089/wor2vec-fine-tuning
<p>I need to fine-tune my word2vec model. I have two datasets, <code>data1</code> and <code>data2</code>.</p> <p>What I did so far is:</p> <pre><code>model = gensim.models.Word2Vec( data1, size=size_v, window=size_w, min_count=min_c, workers=work) model.train(data1, total_example...
<p>Note you <strong>don't</strong> need to call <code>train()</code> with <code>data1</code> if you already provided <code>data1</code> at the time of model instantiation. The model will have already done its own internal <code>build_vocab()</code> and <code>train()</code> on the supplied corpus, using the default numb...
1,122
fine-tuning
Fine tuning BART to generate Summary
https://stackoverflow.com/questions/61863504/fine-tuning-bart-to-generate-summary
<p>I am trying to fine tune the <a href="https://huggingface.co/transformers/model_doc/bart.html#bartforconditionalgeneration" rel="nofollow noreferrer">BART model</a> to generate news headlines. </p> <p>I am taking the dataset from <a href="https://www.kaggle.com/sunnysai12345/news-summary" rel="nofollow noreferrer">...
1,123
fine-tuning
how to do fine-tuning with resnet50 model?
https://stackoverflow.com/questions/46693776/how-to-do-fine-tuning-with-resnet50-model
<p>I have seen many examples in the Internet about how to fine tune VGG16 and InceptionV3.For example, some people will set the first 25 layers to be frozen when fine tuning VGG16. For InceptionV3, the first 172 layers will be frozen. But how about resnet? When we do fine tuning, we will freeze some layers of the base ...
<p>That's curious.... the VGG16 model has a total of 23 layers... (<a href="https://github.com/fchollet/keras/blob/master/keras/applications/vgg16.py" rel="nofollow noreferrer">https://github.com/fchollet/keras/blob/master/keras/applications/vgg16.py</a>)</p> <hr> <p>All these models have a similar strucutre:</p> <u...
1,124
fine-tuning
Fine tuning weights in DBN
https://stackoverflow.com/questions/38182578/fine-tuning-weights-in-dbn
<p>In a Deep Belief Network, I have pretrained the net using CD-1. I have the weights and biases stored. Now can I run a supervised mlp code with dropout and initialise the weights as those obtained from pre training. Will it be equivalent to a DBN implemented with dropout fine tuning?</p>
<blockquote> <p>dropout fine tuning on DBN</p> </blockquote> <p>means </p> <blockquote> <p>run a supervised mlp code with dropout and initialise the weights as those obtained from pre training</p> </blockquote> <p>So yes, they are equivalent.</p>
1,125
fine-tuning
Tensorflow: Fine-Tuning the VGG19 Model [Python]
https://stackoverflow.com/questions/74175610/tensorflow-fine-tuning-the-vgg19-model-python
<p>I have VGG19 Model.</p> <p>Can it be used <code>fine_tune_at = 100</code> ???</p> <p>Is it correct ???</p> <p>I don't understand fine-tuning method.</p> <p>I'm a newbie in both deep learning and tensorflow.</p> <p>Can someone please explain to me ???</p> <p>Thank you.</p> <pre><code>vgg_model.trainable = True </code...
1,126
fine-tuning
PHP REGEX fine-tuning capturing
https://stackoverflow.com/questions/49572379/php-regex-fine-tuning-capturing
<p>I have to process text that comes from student essays (texts can be VERY large).</p> <p>I need in PHP a preg_match for dates inside that strings which may come in this way:</p> <pre><code>...blah blah blah (1994) blah blah blah ... ...blah blah blah (nov-1994) blah blah blah ... ...blah blah blah (november-1994)...
<p>You can use the RegEx <a href="https://regex101.com/r/qUwg5Z/3/" rel="nofollow noreferrer"><code>[(\[](([a-zA-Z]{1,8}-)?(19|20)\d{2}|(19|20)\d{2}-[a-zA-Z]{1,8})[)\]]</code></a></p> <ul> <li><p><code>[(\[] ... [)\]]</code> matches anything inside <code>()</code> or <code>[]</code></p></li> <li><p><code>([a-zA-Z]{1,8...
1,127
fine-tuning
Fine tuning of Bert word embeddings
https://stackoverflow.com/questions/64145666/fine-tuning-of-bert-word-embeddings
<p>I would like to load a pre-trained Bert model and to fine-tune it and particularly the word embeddings of the model using a custom dataset. The task is to use the word embeddings of chosen words for further analysis. It is important to mention that the dataset consists of tweets and there are no labels. Therefore, I...
<p>Since the objective of the masked language model is to predict the masked token, the label and the inputs are the same. So, whatever you have written is correct.</p> <p>However, I would like to add on the concept of comparing word embeddings. Since, BERT is not a word embeddings model, it is contextual, in the sense...
1,128
fine-tuning
gpt3 fine tuning with openai not learning
https://stackoverflow.com/questions/73467393/gpt3-fine-tuning-with-openai-not-learning
<p>For my fine tuning jsonl files, I wanted a model that could predict the gender of the speaker given a statement. For instance, the prompt: &quot;i went to buy a skirt today&quot; has completion as &quot;female&quot;.</p> <p>I created several examples and gave it to gpt3 to finetune. I then fed the sentence &quot;i w...
<ol> <li><p>Open AI Fine Tuning is a process of using a pre-trained model on a new dataset to improve the performance of the model on the new dataset. It is really important to have a specific prompt you are working with so the fine-tuning model knows exactly what you are training for.</p> </li> <li><p>Exactly, the ben...
1,129
fine-tuning
Organize data for transformer fine-tuning
https://stackoverflow.com/questions/70957390/organize-data-for-transformer-fine-tuning
<p>I have a corpus of synonyms and non-synonyms. These are stored in a list of python dictionaries like <code>{&quot;sentence1&quot;: &lt;string&gt;, &quot;sentence2&quot;: &lt;string&gt;, &quot;label&quot;: &lt;1.0 or 0.0&gt; }</code>. Note that this words (or sentences) do not have to be a single token in the tokeniz...
<p>You can use the Tokenizer <code>__call__</code> method to join both sentences when encoding them.</p> <p>In case you're using the PyTorch implementation, here is an example:</p> <pre class="lang-py prettyprint-override"><code>import torch from transformers import AutoTokenizer sentences1 = ... # List containing all...
1,130
fine-tuning
How to Fine-tuning a Pretrained Network in Tensorflow?
https://stackoverflow.com/questions/34984065/how-to-fine-tuning-a-pretrained-network-in-tensorflow
<p>Can anyone give an example of how to fine tune a pretrained imagenet network with new data and different classes similar to this:</p> <p><a href="https://github.com/BVLC/caffe/blob/master/examples/03-fine-tuning.ipynb" rel="noreferrer">Fine-tuning a Pretrained Network for Style Recognition</a></p>
<p>This <a href="https://www.tensorflow.org/tutorials/image_retraining" rel="nofollow noreferrer">TensorFlow tutorial</a> describes how to retrain a image classifier for new data and new classes.</p>
1,131
fine-tuning
Fine-tuning distilbert takes hours
https://stackoverflow.com/questions/74856703/fine-tuning-distilbert-takes-hours
<p>I am fine tuning the distilbert pretrained model for sentiment analysis (multilabel with 6 labels) using Huggingface emotion dataset. I am new to this, but 1 epoch, 250 steps takes around 2 hours to train on Google Colab notebook, is this normal? The train dataset has 16.000 twitter text data which of course affects...
<p>Are you using a GPU? If not, it's normal that it would take this much time. Also, I wouldn't be bothered by the accuracy if you're not able to run it for more epochs.</p>
1,132
fine-tuning
Random Forest Fine-tuning stuck in running
https://stackoverflow.com/questions/66945540/random-forest-fine-tuning-stuck-in-running
<pre><code>rf_classifier = RandomForestClassifier(class_weight = &quot;balanced&quot;, random_state=7) param_grid = {'n_estimators': [50, 75, 100, 125, 150, 175], 'min_samples_split':[2,4,6,8,10], 'min_samples_leaf': [1, 2, 3, 4], 'max_dep...
1,133