C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

Python / matplotlib: print to resolution and without white space / borders / margins

Python / matplotlib: print to resolution and without white space / borders / margins Tag : python , By : walshtp Date : November 25 2020, 03:01 PM

Hope this helps I will neglect the point about more than 30000 points as this is nonsense for printing. So assuming a configuration as implied by the code of some 3000 points or so, you can calculate the figure size needed to show the plot with one point per printable point. You would also need to make sure that the linewidth is actually one dot wide.
``````import numpy as np
Fs = 512
# Create random signal
np.random.seed(1)
data = [np.random.uniform(-10000, 20000) for i in range(5*Fs)]

import matplotlib.pyplot as plt

dpi = 600
figheight = 4 # inch, some constant number

margin_left  = 1.0  # inch
margin_right = 0.4 # inch

figwidth = (len(data)/float(dpi)) + margin_left + margin_right # inch

plt.figure(figsize=(figwidth,figheight), dpi=dpi)
plt.margins(x=0) # remove inner-axis padding of data
right=1.-margin_right/float(figwidth))
# use 72/dpi for linewidth such that one point is one dot
plt.plot(data, color = "black", linewidth = 72./dpi)
plt.savefig("output.png", dpi="figure")
# note that show() may not make sense,
# since it readjusts the figure size to maximum screen size
plt.show()
``````

Share :

Annoying white space in bar chart (matplotlib, Python)

Tag : python , By : Salikh
Date : March 29 2020, 07:55 AM
will be helpful for those in need It's probably a trivial question, but I am trying to plot a bar chart with matplotlib and with rotated text on the x axis. The code I'm using is shown below: , Try calling plt.xlim() with the number of bins, e.g.
``````plt.xlim([0,bins.size])
``````
``````#make some data
N = 22
data = np.random.randint(1,10,N)
bin = np.arange(N)
width = 1

#plot it
ax = plt.subplot(111)
ax.bar(bin, data, width, color='r')
plt.show()
``````
``````#plot it
ax = plt.subplot(111)
ax.bar(bin, data, width, color='r')
plt.xlim([0,bin.size])
plt.show()
``````

ax.fill() in matplotlib creates white margins

Tag : image , By : moss
Date : March 29 2020, 07:55 AM
around this issue Follow-up on my comment: The axis limits have changed. The image is in the rectangle between (0,0) and (500, 600). However the x- and y-lim are not exactly that; they range from (-100, -100) up to (500, 600). Just update the limits with ax.set_xlim([0, 500]) and ax.set_ylim([600, 0]) to remove the white frame around.
Note: if you also want to hide the ticks you easily do this with ax.set_xticks([]) and ax.set_yticks([]), or by setting the visibility of the ticks to False.

White space on top and bottom Python matplotlib plot

Tag : python , By : Steve
Date : March 29 2020, 07:55 AM
around this issue An option is to specify the bounding box of the table as the one to be used when saving the figure.
``````from matplotlib import pyplot as plt

fig, ax = plt.subplots()

colums = ['col1', 'col2']
rows = ['row1', 'row2']
values = [[0, 1], [1, 0]]
table = ax.table(cellText=values, colLabels=colums, rowLabels=rows, loc='center')

ax.axis('off')

fig.canvas.draw()
bbox = table.get_window_extent(fig.canvas.get_renderer())
bbox_inches = bbox.transformed(fig.dpi_scale_trans.inverted())

fig.savefig('plop.png', bbox_inches=bbox_inches)

plt.show()
``````
``````bbox = table.get_window_extent(fig.canvas.get_renderer())
bbox = bbox.from_extents(bbox.xmin-5, bbox.ymin-5, bbox.xmax+5, bbox.ymax+5)
bbox_inches = bbox.transformed(fig.dpi_scale_trans.inverted())
``````

Why is there white space between the rows? I set all the margins and paddings to 0, but I can't get rid of the white spa

Tag : twitter-bootstrap , By : Xander
Date : March 29 2020, 07:55 AM
The border-collapse property sets whether table borders should collapse into a single border or be separated as in standard HTML. The border-spacing property sets the distance between the borders of adjacent cells.
``````table {
...
border-spacing:0;
border-collapse:collapse;
}
``````
``````.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #dee2e6;
}
``````
``````.table td, .table th {

vertical-align: top;
border-top: 1px solid #dee2e6;

}
``````
``````.table thead th {
border-bottom: none !important;
}
.table td, .table th {
border-top:none !important;
}
``````

Eliminate white space margins from Matplotlib graph in Power BI Service

Tag : python , By : user133834
Date : March 29 2020, 07:55 AM