text stringlengths 81 47k | source stringlengths 59 147 |
|---|---|
Question: <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('math... | https://stackoverflow.com/questions/5484922/secondary-axis-with-twinx-how-to-add-to-legend |
Question: <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>
Answer: <p>Use <a href="https://matplotlib.org/api/_as_gen/matplotlib.pyplot.suptitle.html?highlight=suptitle#matplotlib.pyplot.suptitle" rel=... | https://stackoverflow.com/questions/7066121/how-to-set-a-single-main-title-above-all-the-subplots |
Question: <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 ... | https://stackoverflow.com/questions/6871201/plot-two-histograms-on-single-chart |
Question: <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:/... | https://stackoverflow.com/questions/36367986/how-to-make-inline-plots-in-jupyter-notebook-larger |
Question: <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>
Ans... | https://stackoverflow.com/questions/8409095/set-markers-for-individual-points-on-a-line |
Question: <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... | https://stackoverflow.com/questions/14432557/scatter-plot-with-different-text-at-each-data-point |
Question: <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 al... | https://stackoverflow.com/questions/22408237/named-colors-in-matplotlib |
Question: <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 o... | https://stackoverflow.com/questions/4042192/reduce-left-and-right-margins-in-matplotlib-plot |
Question: <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... | https://stackoverflow.com/questions/26597116/seaborn-plots-not-showing-up |
Question: <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,... | https://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined |
Question: <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, a... | https://stackoverflow.com/questions/16150819/common-xlabel-ylabel-for-matplotlib-subplots |
Question: <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>
<... | https://stackoverflow.com/questions/14908576/how-to-remove-frame-from-a-figure |
Question: <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>p... | https://stackoverflow.com/questions/18176591/importerror-no-module-named-matplotlib-pyplot |
Question: <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 fig... | https://stackoverflow.com/questions/10388462/matplotlib-different-size-subplots |
Question: <p>How do I add a horizontal line to an existing plot?</p>
Answer: <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>... | https://stackoverflow.com/questions/33382619/plot-a-horizontal-line-on-a-given-plot |
Question: <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 prog... | https://stackoverflow.com/questions/458209/is-there-a-way-to-detach-matplotlib-plots-so-that-the-computation-can-continue |
Question: <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 a... | https://stackoverflow.com/questions/8248467/tight-layout-doesnt-take-into-account-figure-suptitle |
Question: <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 a... | https://stackoverflow.com/questions/13784201/how-to-have-one-colorbar-for-all-subplots |
Question: <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 circl... | https://stackoverflow.com/questions/9215658/plot-a-circle-with-matplotlib-pyplot |
Question: <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>
Answer: <p... | https://stackoverflow.com/questions/14762181/adding-a-y-axis-label-to-secondary-y-axis-in-matplotlib |
Question: <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.bon... | https://stackoverflow.com/questions/9012487/savefig-outputs-blank-image |
Question: <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 mat... | https://stackoverflow.com/questions/11837979/removing-white-space-around-a-saved-image |
Question: <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... | https://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box |
Question: <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 ... | https://stackoverflow.com/questions/11874767/how-do-i-plot-in-real-time-in-a-while-loop |
Question: <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('d... | https://stackoverflow.com/questions/37435369/how-to-draw-a-rectangle-on-image |
Question: <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... | https://stackoverflow.com/questions/29432629/plot-correlation-matrix-using-pandas |
Question: <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 w... | https://stackoverflow.com/questions/6146778/matplotlib-legend-markers-only-once |
Question: <p>Instead of the default "boxed" axis style I want to have only the left and bottom axis, i.e.:</p>
<pre><code>+------+ |
| | |
| | ---> |
| | |
+------+ +-------
</code></pre>
<p>This should be easy, but I can't find the necessary options in the docs.</... | https://stackoverflow.com/questions/925024/how-can-i-remove-the-top-and-right-axis |
Question: <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>... | https://stackoverflow.com/questions/3823752/display-image-as-grayscale |
Question: <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 c... | https://stackoverflow.com/questions/25408393/getting-individual-colors-from-a-color-map-in-matplotlib |
Question: <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>
<... | https://stackoverflow.com/questions/11244514/modify-tick-label-text |
Question: <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 m... | https://stackoverflow.com/questions/21884271/warning-about-too-many-open-figures |
Question: <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></... | https://stackoverflow.com/questions/5147112/how-to-put-individual-tags-for-a-matplotlib-scatter-plot |
Question: <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... | https://stackoverflow.com/questions/13714454/specifying-and-saving-a-figure-with-exact-size-in-pixels |
Question: <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 su... | https://stackoverflow.com/questions/9834452/how-do-i-make-a-single-legend-for-many-subplots |
Question: <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... | https://stackoverflow.com/questions/12957582/plot-yerr-xerr-as-shaded-region-rather-than-error-bars |
Question: <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... | https://stackoverflow.com/questions/26540035/rotate-label-text-in-seaborn |
Question: <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-va... | https://stackoverflow.com/questions/11264521/date-ticks-and-rotation |
Question: <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 (Python)">Looping over files and plotting</a>. However, saving the picture by clic... | https://stackoverflow.com/questions/39870642/how-to-plot-a-high-resolution-graph |
Question: <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 cla... | https://stackoverflow.com/questions/8209568/how-do-i-draw-a-grid-onto-a-plot-in-python |
Question: <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... | https://stackoverflow.com/questions/2849286/how-to-set-the-subplot-axis-range |
Question: <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 <c... | https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable |
Question: <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 t... | https://stackoverflow.com/questions/28269157/plotting-in-a-non-blocking-way-with-matplotlib |
Question: <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... | https://stackoverflow.com/questions/4931376/generating-matplotlib-graphs-without-a-running-x-server |
Question: <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 ... | https://stackoverflow.com/questions/12236566/setting-different-color-for-each-series-in-scatter-plot |
Question: <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 transparen... | https://stackoverflow.com/questions/4320021/matplotlib-transparent-line-plots |
Question: <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,... | https://stackoverflow.com/questions/21487329/add-x-and-y-labels-to-a-pandas-plot |
Question: <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>
Answer: <p>Matplotlib does this by def... | https://stackoverflow.com/questions/4805048/how-to-get-different-colored-lines-for-different-plots-in-a-single-figure |
Question: <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 d... | https://stackoverflow.com/questions/33282368/plotting-a-2d-heatmap |
Question: <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... | https://stackoverflow.com/questions/15713279/calling-pylab-savefig-without-display-in-ipython |
Question: <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... | https://stackoverflow.com/questions/37427362/plt-show-shows-full-graph-but-savefig-is-cropping-the-image |
Question: <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 b... | https://stackoverflow.com/questions/42086276/get-default-line-color-cycle |
Question: <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 rotat... | https://stackoverflow.com/questions/14852821/aligning-rotated-xticklabels-with-their-respective-xticks |
Question: <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... | https://stackoverflow.com/questions/36327134/matplotlib-error-no-module-named-tkinter |
Question: <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>#cre... | https://stackoverflow.com/questions/37970424/what-is-the-difference-between-drawing-plots-using-plot-axes-or-figure-in-matpl |
Question: <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, xmi... | https://stackoverflow.com/questions/16930328/vertical-horizontal-lines-in-matplotlib |
Question: <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>
Answer: <p>When plotting a plot using matplotlib:</p>
<p>How to remove th... | https://stackoverflow.com/questions/25540259/remove-or-adapt-border-of-frame-of-legend-using-matplotlib |
Question: <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.subpl... | https://stackoverflow.com/questions/15858192/how-to-set-xlim-and-ylim-for-a-subplot |
Question: <p>Given a mean and a variance is there a simple function call which will plot a normal distribution?</p>
Answer: <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, ... | https://stackoverflow.com/questions/10138085/how-to-plot-normal-distribution |
Question: <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 vlgaBuffSor... | https://stackoverflow.com/questions/4098131/how-to-update-a-plot-in-matplotlib |
Question: <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 ... | https://stackoverflow.com/questions/6963035/how-to-set-common-axes-labels-for-subplots |
Question: <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 mat... | https://stackoverflow.com/questions/20057260/how-to-remove-gaps-between-subplots |
Question: <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, ... | https://stackoverflow.com/questions/10965417/how-to-convert-a-numpy-array-to-pil-image-applying-matplotlib-colormap |
Question: <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>
Answer: <p>You ca... | https://stackoverflow.com/questions/18195758/set-matplotlib-colorbar-size-to-match-graph |
Question: <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]... | https://stackoverflow.com/questions/741877/how-do-i-tell-matplotlib-that-i-am-done-with-a-plot |
Question: <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):
######... | https://stackoverflow.com/questions/11744990/how-to-set-auto-for-upper-limit-but-keep-a-fixed-lower-limit |
Question: <p><strong>What are the pros & 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 u... | https://stackoverflow.com/questions/5446316/code-first-vs-model-database-first |
Question: <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 task... | https://stackoverflow.com/questions/76461859/lmm-fine-tuning-supervised-fine-tuning-trainer-sfttrainer-vs-transformers-tr |
Question: <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 w... | https://stackoverflow.com/questions/72774975/fine-tuning-blenderbot |
Question: <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 ... | https://stackoverflow.com/questions/45134834/fine-tuning-vs-retraining |
Question: <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 g... | https://stackoverflow.com/questions/50909726/fine-tuning-glove-embeddings |
Question: <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 netw... | https://stackoverflow.com/questions/60418179/bert-fine-tuning |
Question: <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>
Answer: <p>Assuming you are trying to do image classification. These should... | https://stackoverflow.com/questions/36841158/fine-tuning-of-googlenet-model |
Question: <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,... | https://stackoverflow.com/questions/45689296/fine-tuning-vbscript |
Question: <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 f... | https://stackoverflow.com/questions/62210883/fine-tuning-inceptionv3 |
Question: <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>
Answer: <p>See <a href="https://github.com/amaiya/ktrain/blob/master/FAQ.md#how-do-i-resume-training-from-a-saved-checkpoint" rel="nofollow ... | https://stackoverflow.com/questions/67318099/how-to-fine-tuning-again-of-a-bert-fined-tuned-model |
Question: <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&uniqifier=3" rel="nofollow noreferrer">https://colab.research.go... | https://stackoverflow.com/questions/73916442/fine-tuning-stable-diffusion |
Question: <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
+---------------------------------------------------------------------------------------+
| N... | https://stackoverflow.com/questions/78364403/spacy-fine-tuning-gpu |
Question: <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.0... | https://stackoverflow.com/questions/58939250/vgg16-fine-tuning |
Question: <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>bn... | https://stackoverflow.com/questions/78869197/why-8bit-quantized-fine-tuning-of-a-model-occupy-more-memory-than-just-original |
Question: <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... | https://stackoverflow.com/questions/69562624/fine-tuning-bert-sentence-transformer-model |
Question: <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 g... | https://stackoverflow.com/questions/19658887/rrd-fine-tuning |
Question: <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 tra... | https://stackoverflow.com/questions/48085257/inception-v3-fine-tuning |
Question: <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 Baze... | https://stackoverflow.com/questions/45071647/tensorflow-fine-tuning-tutorial-without-bazel |
Question: <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 "ada", "babbage", "curie", "davinci", or a fi... | https://stackoverflow.com/questions/72758187/openai-gpt-3-api-fine-tune-a-fine-tuned-model |
Question: <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 block... | https://stackoverflow.com/questions/43386463/keras-vgg16-fine-tuning |
Question: <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 stil... | https://stackoverflow.com/questions/40345607/how-does-fine-tuning-word-embeddings-work |
Question: <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... | https://stackoverflow.com/questions/73799136/fine-tuning-resnet18-for-cifar10 |
Question: <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, tot... | https://stackoverflow.com/questions/56166089/wor2vec-fine-tuning |
Question: <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 no... | https://stackoverflow.com/questions/61863504/fine-tuning-bart-to-generate-summary |
Question: <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... | https://stackoverflow.com/questions/46693776/how-to-do-fine-tuning-with-resnet50-model |
Question: <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>
Answer: <blockquot... | https://stackoverflow.com/questions/38182578/fine-tuning-weights-in-dbn |
Question: <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 = T... | https://stackoverflow.com/questions/74175610/tensorflow-fine-tuning-the-vgg19-model-python |
Question: <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 (nove... | https://stackoverflow.com/questions/49572379/php-regex-fine-tuning-capturing |
Question: <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.
Th... | https://stackoverflow.com/questions/64145666/fine-tuning-of-bert-word-embeddings |
Question: <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: "i went to buy a skirt today" has completion as "female".</p>
<p>I created several examples and gave it to gpt3 to finetune. I then fed the sentence... | https://stackoverflow.com/questions/73467393/gpt3-fine-tuning-with-openai-not-learning |
Question: <p>I have a corpus of synonyms and non-synonyms. These are stored in a list of python dictionaries like <code>{"sentence1": <string>, "sentence2": <string>, "label": <1.0 or 0.0> }</code>. Note that this words (or sentences) do not have to be a single token in t... | https://stackoverflow.com/questions/70957390/organize-data-for-transformer-fine-tuning |
Question: <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>
Answer... | https://stackoverflow.com/questions/34984065/how-to-fine-tuning-a-pretrained-network-in-tensorflow |
Question: <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 cour... | https://stackoverflow.com/questions/74856703/fine-tuning-distilbert-takes-hours |
Question: <pre><code>rf_classifier = RandomForestClassifier(class_weight = "balanced",
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],
... | https://stackoverflow.com/questions/66945540/random-forest-fine-tuning-stuck-in-running |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.