Python printing tabular data breaks with Google fonts - python-3.x
I'm using the Tabulate package to print data in table format. The output is sent to a webpage. While using the default font everything is working fine. However upon changing font family (Outfit from Google fonts or cursive e.g), they stop being aligned. Are there any possible solutions?
Output with default font:
Strength: 16 Dmg: 50 Armor: 3.8 ShadowRes: 3.5%
Agility: 34 Spell: 183 FireRes: 5.1% NatureRes: 6.1%
Intellect: 61 Critical: 3.4% FrostRes: 6.3% ArcaneRes: 3.8%
Output with Google font (looks like this can't really show it because SO font is the default):
Strength: 25 Dmg: 45 Armor: 3.1 ShadowRes: 3.2%
Agility: 20 Spell: 132 FireRes: 3.3% NatureRes: 3.6%
Intellect: 44 Critical: 2.0% FrostRes: 3.6% ArcaneRes: 3.8%
Thanks in advance!
you need a monospace font in order to keep the good size of space
Related
SVG <path > strokes and detexify database 'strokes'. How to go from on to the other?
I am trying to generate handwritten math text by using mathjax to convert tex to svg and then change svg paths to "strokes" obtained from detexify database github. How can one convert Detexify's strokes: The „strokes“ column contains an array of strokes each of which contains an array of [x,y,t] triples. [[[x1,y1,t1], [x2,y2,t2], …], …]. to the svg format. Example: take latex \sqrt For an svg file: <path id="MJX-15-TEX-SO-221A" d="M263 249Q264 249 315 130T417 -108T470 -228L725 302Q981 837 982 839Q989 850 1001 850Q1008 850 1013 844T1020 832V826L741 243Q645 43 540 -176Q479 -303 469 -324T453 -348Q449 -350 436 -350L424 -349L315 -96Q206 156 205 156L171 130Q138 104 137 104L111 130L263 249Z"></path> Detexify provides us with : [[[134.5,170.125,1390746601343],[134.5,170.125,1390746601362],[134.5,170.125,1390746601369],[134.5,170.125,1390746601379],[135.5,170.125,1390746601548],[136.5,170.125,1390746601575],[143.5,170.125,1390746601599],[144.5,170.125,1390746601605],[147.5,170.125,1390746601623],[149.5,171.125,1390746601636],[150.5,171.125,1390746601656],[151.5,172.125,1390746601672],[152.5,172.125,1390746601682],[153.5,172.125,1390746601694],[153.5,173.125,1390746601708],[154.5,173.125,1390746601716],[155.5,173.125,1390746601734],[155.5,174.125,1390746601749],[155.5,175.125,1390746601925],[156.5,175.125,1390746601933],[156.5,176.125,1390746601940],[156.5,178.125,1390746601955],[156.5,179.125,1390746601964],[156.5,180.125,1390746601972],[156.5,181.125,1390746601981],[156.5,182.125,1390746601990],[156.5,183.125,1390746601998],[156.5,184.125,1390746602013],[156.5,185.125,1390746602022],[156.5,186.125,1390746602029],[156.5,187.125,1390746602040],[156.5,188.125,1390746602044],[156.5,190.125,1390746602056],[156.5,191.125,1390746602061],[156.5,193.125,1390746602076],[156.5,194.125,1390746602092],[156.5,195.125,1390746602108],[156.5,196.125,1390746602116],[156.5,197.125,1390746602132],[156.5,198.125,1390746602150],[156.5,199.125,1390746602156],[156.5,200.125,1390746602172],[156.5,201.125,1390746602196],[156.5,201.125,1390746602206],[156.5,202.125,1390746602212],[156.5,203.125,1390746602222],[156.5,204.125,1390746602237],[156.5,205.125,1390746602245],[156.5,206.125,1390746602255],[156.5,207.125,1390746602260],[156.5,208.125,1390746602272],[156.5,207.125,1390746602397],[156.5,206.125,1390746602405],[157.5,205.125,1390746602412],[157.5,203.125,1390746602422],[158.5,201.125,1390746602428],[158.5,200.125,1390746602439],[158.5,198.125,1390746602444],[158.5,195.125,1390746602455],[158.5,193.125,1390746602460],[159.5,191.125,1390746602472],[159.5,190.125,1390746602476],[160.5,188.125,1390746602490],[160.5,187.125,1390746602495],[160.5,186.125,1390746602506],[160.5,184.125,1390746602509],[160.5,183.125,1390746602524],[160.5,182.125,1390746602532],[160.5,181.125,1390746602540],[160.5,180.125,1390746602556],[160.5,179.125,1390746602564],[161.5,175.125,1390746602582],[161.5,173.125,1390746602591],[162.5,171.125,1390746602599],[162.5,168.125,1390746602606],[163.5,166.125,1390746602614],[163.5,163.125,1390746602622],[164.5,160.125,1390746602629],[164.5,158.125,1390746602640],[164.5,156.125,1390746602643],[165.5,154.125,1390746602656],[165.5,152.125,1390746602659],[165.5,150.125,1390746602673],[165.5,149.125,1390746602677],[165.5,148.125,1390746602691],[165.5,146.125,1390746602694],[165.5,145.125,1390746602708],[165.5,144.125,1390746602724],[165.5,143.125,1390746602732],[165.5,142.125,1390746602780],[165.5,141.125,1390746602805],[165.5,140.125,1390746602828],[164.5,140.125,1390746602836],[164.5,139.125,1390746602861],[164.5,138.125,1390746602940],[165.5,138.125,1390746603293],[166.5,138.125,1390746603306],[168.5,138.125,1390746603313],[171.5,138.125,1390746603323],[174.5,139.125,1390746603326],[177.5,139.125,1390746603340],[180.5,139.125,1390746603344],[183.5,139.125,1390746603356],[187.5,139.125,1390746603359],[194.5,140.125,1390746603373],[197.5,140.125,1390746603382],[200.5,140.125,1390746603390],[203.5,140.125,1390746603398],[205.5,140.125,1390746603407],[207.5,140.125,1390746603416],[208.5,140.125,1390746603423],[210.5,140.125,1390746603440],[211.5,140.125,1390746603446],[212.5,140.125,1390746603461],[212.5,141.125,1390746603469],[213.5,141.125,1390746603477],[214.5,141.125,1390746603493],[215.5,141.125,1390746603517],[216.5,142.125,1390746603525],[217.5,142.125,1390746603541],[218.5,143.125,1390746603549],[219.5,143.125,1390746603557],[220.5,143.125,1390746603573],[221.5,143.125,1390746603582],[222.5,143.125,1390746603590],[223.5,143.125,1390746603598],[225.5,143.125,1390746603613],[226.5,143.125,1390746603629],[227.5,143.125,1390746603639],[228.5,143.125,1390746603645],[229.5,143.125,1390746603661],[229.5,144.125,1390746603677],[230.5,144.125,1390746603690]]]
Plot the x,y as a polyline and ignore the t values. If you really want to use a path then stick an M in the front and similarly add all the x,y values ignoring the t values. When you've got that working you can delay adding each vertex to the polyline/path by the time delta tn+1-tn
Get bounding box of SVG path
I want exactly what this page do http://codepen.io/netsi1964/full/vNoemp/ I have the path and need to know it's bounding box as a rect element, it's x,y,width and height given code <path d="M147.5 55.8c-5.8-7.2-13.6-14.4-25.5-14.4-8.4 0-15.4 8.2-27 8.2-9 0-13-7.8-23-7.8C51.4 41.8 31 60.4 31 84.5c0 12.8 4.2 32.5 13.6 49.7C51 146.7 59.4 155 69 155c6.7 0 14.7-6.3 24.2-6.3 8.4 0 16.2 5.6 23.8 5.6 18 0 35-23.5 35-39.3 0-.8-.3-1.4-.3-2v-1c-11.8-6.3-18.2-15.7-18.2-29.3 0-11 4.8-20.5 13.6-26.7l.5-.2zm-53-8.8c13.7-4.2 26.3-14.4 26.3-32 0-1.5-.2-3.3-.4-5.3l-.2-.8C106.4 12.6 94 23.4 94 40.3c0 1.6.2 3.6.6 5.8v.8z" style="translate(0px,-212.47488403320312px) scale(1,1)" > and know the rect properties
With pure JavaScript: give your path an ID and get its bounding box using getBBox(). var myPathBox = document.getElementById("myPath").getBBox(); console.log(myPathBox); Here is a demo: var myPathBox = document.getElementById("myPath").getBBox(); console.log(myPathBox); <svg width="400" height="400"> <path id="myPath" d="M147.5 55.8c-5.8-7.2-13.6-14.4-25.5-14.4-8.4 0-15.4 8.2-27 8.2-9 0-13-7.8-23-7.8C51.4 41.8 31 60.4 31 84.5c0 12.8 4.2 32.5 13.6 49.7C51 146.7 59.4 155 69 155c6.7 0 14.7-6.3 24.2-6.3 8.4 0 16.2 5.6 23.8 5.6 18 0 35-23.5 35-39.3 0-.8-.3-1.4-.3-2v-1c-11.8-6.3-18.2-15.7-18.2-29.3 0-11 4.8-20.5 13.6-26.7l.5-.2zm-53-8.8c13.7-4.2 26.3-14.4 26.3-32 0-1.5-.2-3.3-.4-5.3l-.2-.8C106.4 12.6 94 23.4 94 40.3c0 1.6.2 3.6.6 5.8v.8z" style="translate(0px,-212.47488403320312px) scale(1,1)" > </svg>
I know this is an old issue, but thought I would put this variant to Furtado's answer for reference here. An easy way to get the bounding box for the path. Make sure the path (or any other SVG element has an id on it. Open the svg file in Chrome (or FF or probably IE). Inspect the image Open the console in the inspection tool. Enter the JS: document.getElementById("myPath").getBBox(); (where myPath is the id) The bounding box info will be displayed in the console. Same method, just no need for custom code.
Correlation analysis between stock prices
Let us consider following stock prices taken from yahoo.finance.com: Date Open High Low Close Volume Adj Close 3/4/2013 23.15 23.84 23.03 23.67 30908300 23.3 2/25/2013 23.5 23.53 22.81 23.19 40710800 22.83 2/19/2013 23.42 23.75 23.12 23.39 38743400 23.03 2/11/2013 22.49 23.55 22.35 23.29 46448500 22.74 2/4/2013 22.41 22.62 22.27 22.5 34498100 21.97 1/28/2013 22.44 22.64 22.18 22.62 39634900 22.09 1/22/2013 22.18 22.31 21.75 22.29 47826300 21.77 1/14/2013 21.18 22.19 21.01 22.04 54826000 21.52 1/7/2013 21.16 21.24 20.68 21.13 35304100 20.63 12/31/2012 20.29 21.54 20.26 21.2 45796500 20.7 12/24/2012 20.79 20.96 20.42 20.44 28597100 19.96 12/17/2012 21.69 21.95 20.56 20.88 70719700 20.39 12/10/2012 21.43 21.95 21.36 21.62 39455500 20.92 12/3/2012 21.18 21.48 20.71 21.46 35913000 20.77 11/26/2012 20.88 21.36 20.5 21.13 36203100 20.45 11/19/2012 20.41 21.04 20.37 21.04 35401500 20.36 11/12/2012 21.04 21.14 19.87 20.15 45095400 19.5 11/5/2012 21.2 21.78 20.7 21 37812800 20.32 11/2/2012 21.53 21.68 21.26 21.31 47475200 20.62 And i want to do correlation matrix between for example Volume and Low Close variable. I used correlation function from data analysis toolbox from excel, but I got only one side matrix, like this: Close Volume Close 1 Volume -0.117267345 1 It does not show me correlation coefficients up side of main diagonal, why? Maybe it is symmetric and because of this?
The correlation matrix is necessarily symmetric, so the above the diagonal element in your case is -0.117257345. If you check the documentation on the correl function, and look at the defining equation, you can see that it is symmetric with respect to exchanging X<->Y
How do I control PDF paper size with ImageMagick?
I have 16 jpg files which are around 920x1200 pixels (the widths slightly differ but heights are all 1200). I'm trying to join them into a pdf with: convert *.jpg foo.pdf But the resulting paper size is 1.53x2 inches. If I pass the arguments -page Letter, the page size ends up being a bewildering 1.02x1.32 inches. What is going wrong here? All of the information I can find suggests that this should work. I just want a document that consists of 16 letter-size pages.
This question is pretty old, but I had a similar problem and I think I found the solution. The documentation for the -page option says "This option is used in concert with -density", but the relationship between the options seems a little unclear, possibly because the documentation is geared towards raster images. From experimenting with the settings, I found that the pdf page size can be controlled by combining -page -density and -units. The documentation for -page shows that letter is the same as entering 612 x 792. Combining -density 72 with -units pixelsperinch will give you (612px /72px) * 1in = 8.5in. convert *.jpg -units pixelsperinch -density 72 -page letter foo.pdf should do what the original poster wanted.
I just succeeded with convert file.mng -page letter file.pdf
For Letter, you need to specify the size as 792x612 PostScript points. Therefor try this command: convert \ in1.jpg \ in2.jpg \ in3.jpg \ in4.jpg \ in5.jpg \ -gravity center \ -resize 792x612\! \ letter.pdf Works for me with ImageMagick version 6.7.8-3 2012-07-19 Q16 on Mac OS X: identify -format "%f[%s] : %W x %H\n" letter.pdf letter.pdf[0] : 792 x 612 letter.pdf[1] : 792 x 612 letter.pdf[2] : 792 x 612 letter.pdf[3] : 792 x 612 letter.pdf[4] : 792 x 612 Or pdfinfo -f 1 -l 5 letter.pdf Title: _ Producer: ImageMagick 6.7.8-3 2012-07-19 Q16 http://www.imagemagick.org CreationDate: Fri Jul 27 22:28:00 2012 ModDate: Fri Jul 27 22:28:00 2012 Tagged: no Form: none Pages: 5 Encrypted: no Page 1 size: 792 x 612 pts (letter) Page 1 rot: 0 Page 2 size: 792 x 612 pts (letter) Page 2 rot: 0 Page 3 size: 792 x 612 pts (letter) Page 3 rot: 0 Page 4 size: 792 x 612 pts (letter) Page 4 rot: 0 Page 5 size: 792 x 612 pts (letter) Page 5 rot: 0 File size: 178642 bytes Optimized: no PDF version: 1.3
According to this, 72 dpi is the default density => one dot per pixel (for a computer screen). So you just need to specify -units pixelsperinch. You can type the following command : $ convert *.jpg -units pixelsperinch -page letter foo.pdf BTW : If you want to use a non standard page size such as A4R for example, you must first determine the page size in dots (or pixels given at 72dpi) : $ paperconf -s -p A4 595.276 841.89 Then the -page argument for A4R will be 842x595
How to define a unsupported screen resolution in Linux's framebuffer?
I have an LCD monitor that supports hsync between 30 to 82 kHz and vsync 50-85kHz. Lowest supported resolution is 640x350. I want to run it in 400x240 resolution. I think I need to edit the modedb structure in modedb.c and I have just figured out what the fields require: I ran cvt with max vsync (85 kHz) and got a modeline like this: Modeline "400x240_85.00" 10.50 400 416 448 496 240 243 253 256 -hsync +vsync I used a calculator to calculate hsync and vsync and hsync would be 21.17 kHz, way too low for this monitor. Is there a way to get around this? I want to test how certain things work on that resolution, so even cheating the monitor by running it in say 800x480 (this would produce acceptable hsync and vsync) would be ok as long as X and applications on top of it handle it like it was 400x240.
"Sharp-VGA", 56, 800, 480, 33805, 84, 40, 35, 1, 80, 3, 0 | FB_SYNC_OE_ACT_HIGH, FB_VMODE_NONINTERLACED, 0, try that one, found in 2.6.19.2 with freescale patching Edit: Actually, if you use fbset and the mode is readable from /etc/fb.modes you should be able to use this too: mode "800x480" geometry 800 480 800 480 16 timings 33805 90 50 35 1 80 3 accel false rgba 5/11,6/5,5/0,0/0 endmode eg: fbset -n 800x480 # mode # geometry <xres> <yres> <vxres> <vyres> <depth> # timings <pixclock> <left> <right> <upper> <lower> <hslen> <vslen> # options <value> # rgba <red,green,blue,alpha> # endmode