plot
How to decrease density of tick labels in subplots
A general approach is to tell matplotlib the desired number of ticks: plt.locator_params(nbins=10) Edit by comments from @Daniel Power: to change for a single axis (e.g. ‘x’) on an axis, use: ax.locator_params(nbins=10, axis=”x”)
Getting information for bins from the histogram function
The return values of plt.hist are: Returns: tuple : (n, bins, patches) or ([n0, n1, …], bins, [patches0, patches1,…]) So all you need to do is capture the return values appropriately. For example: import numpy as np import matplotlib.pyplot as plt # generate some uniformly distributed data x = np.random.rand(1000) # create the histogram (n, … Read more
Adding caption below X-axis for a scatter plot using matplotlib
You can simply use figtext. You can also change the value of x and y-axes as you want. txt=”I need the caption to be present a little below X-axis” plt.figtext(0.5, 0.01, txt, wrap=True, horizontalalignment=”center”, fontsize=12)
Change transparency of fillcolor
You would need to use rgba to specify the alpha channel as well, rgb ignores the transparency. import plotly trace = plotly.graph_objs.Scatter(x=[30,45],y=[3000,3000], fill=”tozeroy”, fillcolor=”rgba(26,150,65,0.5)”, mode=”none”) plotly.offline.iplot(plotly.graph_objs.Figure(data=[trace]))
Plotting a list of (x, y) coordinates
Given li in the question: li = list(zip(range(1, 14), range(14, 27))) To unpack the data from pairs into lists use zip: x, y = zip(*li) x → (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13) y → (14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26) … Read more
Plotting labeled intervals in matplotlib/gnuplot
Updated: Now includes handling the data sample and uses mpl dates functionality. import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter, MinuteLocator, SecondLocator import numpy as np from StringIO import StringIO import datetime as dt ### The example data a=StringIO(“””a 10:15:22 10:15:30 OK b 10:15:23 10:15:28 OK c 10:16:00 10:17:10 FAILED b 10:16:30 10:16:50 OK “””) … Read more
How to change axis linewidth and fontsize in Octave
With octave 3.8.2 it is working fine. x=1:10; plot(x, x, “linewidth”, 5) set(gca, “linewidth”, 4, “fontsize”, 12) yields as it should