I'm using the IPython Notebook. So far all I've got is:
from IPython.core.display import Image
Image(filename='gibbs.png')
Which indeed displays the image very well. What I want now is to add a few textboxes and arrows pointing at specific zones in the picture, ideally all within code (instead of drag-and-dropping).
Something tells me I'll probably have to do it in Matplotlib, but I want to know what are the best practices.
You could use matplotlib to do this. The annotate function will allow you to include arrows and text. If you want the text without the arrow, then omit the "arrowprops" part. If you want the arrow but not text, then just include an empty string.
Try this code:
import matplotlib.pyplot as plt
data = plt.imread('gibbs.png')
plt.imshow(data)
plt.annotate('Label A',xy=(81,130),xytext=(150,200),arrowprops=dict(facecolor='red'))
plt.show()
Here is the output that I get, assuming that you are using a png of J. Willard Gibbs:
Related
I'm using VS Code to edit my markdown file, and need to make flowcharts (graph) to display workflow.
The problem is VS Code will not properly display the long text title, the last few part will be truncated as showed in follow:
```mermaid
graph LR
azzzzzzzz-->b
```
So I'm thinking of simply adding space after the text. However, I searched through the internet, and cannot find a way to type in multiple space.
```mermaid
graph LR
a[zzz z zzzz ]-->b
```
No matter what I try, the actual title will only display 1 space only. So if anyone can help either on truncate issue of VS Code or teach me how to type in multiple space.
I've been struggling with it for whole day, please help! Thanks a lot!
According to documentation Entity codes to escape characters you have to use the following:
It is possible to escape characters using the syntax examplified here.
graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"]
In your example it could be the following:
```mermaid
graph LR
a["zzz #nbsp; z #nbsp; zzzz #nbsp; "]-->b
```
I tried using Ag-Grid, and faced a challenge to plot the data for Special Symbol, It actually doesn't support the special symbol and doesn't plot it!!
Refer To Example1.png, here the No. Column Doesn't contain data,
but when I remove the dot operator from my script.js file from headerName,
and rowData, it starts plotting it. (Refer To Example2.png)
Also attached a zip file (Google Drive Link) as a prototype of this problem for your reference!
https://drive.google.com/open?id=1UqyrRtAhg8-HBwqVqUT_CGMhwyr_cOUt
Kushagra
You probably just need to set the suppressFieldDotNotation grid option to true:
suppressFieldDotNotation
If true, then dots (eg address.firstline) in field names are not treated as deep references. Allows you to use dots in your field name
if you prefer.
(You didn't show any code and I'm not looking in a .zip.)
Alternatively, you can have dots in your headerName, they just can't be in your field name.
Hello last_hope_community, ;)
I have tried several options of exporting, the standard export. Works well to SVG.
load patients
figure
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus');
saveas(gcf,["test_heatp_save_svg.svg"],'svg') %no export style-> fonts gets embedded
%print(gcf,["test_heatp_print_pdf"],'-dpdf','-bestfit','-r0')
Saveas and print, but here is point 1.
For setprinttemplate one can not adopt the styles from the exportsetup (hgexport and so on). Print has the very nicy opportunity of -bestfit which one can use with print to pdf(with print fonts are embedded automatically) and then to import in Inkscape to use as SVG. But when styles are adopted, by export manually to save it then as SVG within the exportdlg or with saveas, all fonts gets vectorpaths.
Is there a way to apply export styles automatically and then get an SVG File in which the fonts are embedded in SVG like in the upper code?
I have already checked if it is just a heatmap issue but it is not. Same with the following code, without export_style everything is great. But with export style everything gets to vector paths.
figure
plot(1:10000)
title('Hallo')
saveas(gcf,["test_simple_save_svg.svg"],'svg')
%print(gcf,["test_simple_print_pdf"],'-dpdf','-bestfit','-r0')
Best would be if anyone knows a way to apply exportstyles programatically and to then save as svg with embedded font, or apply exportstyles programmatically and then print to pdf with -bestfit,export as pdf would just embed the titles and not the TickLabels.
Additional print with bestfit is not always good because the result from the figure window varies from time to time a lot.
Thanks for help, it's annoying that export as svg makes paths from text that one cannot customize with other programms.
I am trying to import a histogram produced by Stata as an .eps file into Mathematica, but it does not display axes' labels. That is, for some reason, Mathematica does not import .eps as but rather transforms it.
How can I avoid that? As of now, I am using plain
Import["~/hst.eps"]
I had a similar problem with LateX and a pdf graph recently, which also manifested itself with the eps version. I wound up modifying the user-written graphexportpdf and things seemed to work out. Perhaps you will find this solution helpful.
Mathematica currently (v.9) usually cannot import textual elements from .eps files properly. One possible solution would be to export your plot as .pdf rather than .eps from you plotting software and then Import generated .pdf. If you need to import the text as text you can turn off outlining by using the "TextOutlines" -> False option.
If exporting to .pdf from your plotting software is not possible you can convert .eps to .pdf by another program and then Import generated .pdf as above.
For your file orders_weekly.eps using the gsEPS2PDFEmbedFonts function and then Importing generated .pdf, I get (Mathematica 8.0.4):
gsEPS2PDFEmbedFonts["orders_weekly.eps", "orders_weekly.pdf"]
graphics=First#Import["orders_weekly.pdf"(*,"TextOutlines"->False*)];
Show[graphics, Frame -> True, PlotRange -> All, ImageSize -> Automatic]
I have commented the "TextOutlines" -> False option because Mathematica 8.0.4 still imports rotated text incorrectly with it. I haven't tested it with v.9 though.
Another possibility is to convert all the glypth in the .eps file to oultines. Based on Jens Nöckel's code,
gsEPS2outlinedEPS[epsPath_String, outlinedEPSPath_String] :=
Run["gswin64c.exe -sDEVICE=epswrite -dNOCACHE -sOutputFile=\"" <>
outlinedEPSPath <> "\" -q -dbatch -dNOPAUSE \"" <> epsPath <>
"\" -c quit"]
Here gswin64c.exe is the name of GhostScript executable for 64bit Windows systems, for Linux replace it with gs.
Note that you should have GhostScript installed and configured (for Windows you should add gs\bin and gs\lib to the PATH, where gs is the top-level Ghostscript directory)
Please can any one help me. I am really stuck I don't know how to highlight particular line of pdf. It would be better if any one can provide me sample code or pseudo code
Thanks
This is not trivial.
To do this, I'd render the PDF contents into one layer, and somehow get the position of the said line/object using the CoreGraphics PDF parser (or some other way). After that, you highlight the said object using your own drawing code.
Just highlighting a particular line is quite difficult.
If you need search and highlight, please try FastPDFKit. I played with it for a while and it's quite good as a pdf reader.
http://mobfarm.eu/fastpdfkit
I'm working on the same thing at the moment and it's not trivial indeed.
From what I can figure out you need to load the text and arrange it in lines first. If you are using Poppler, the Poppler.Page.textList() will provide you with a list of TextBoxes and a TextBox.hasSpaceAfter() will tell you the end of line when returning False.
I am using the Qt4 frontend, so the each TextBox has a QRect from which I can figure out where to highlight a word. Highlighting a line is more or less lirstWordOfLine.geometry().united(lastWordOfLine.geometry()) which will provide the geometry of the line to highlight.
Now what I can't figure out is how to save the coordinates of the highlights in the document.