Let's say that I have two Raster objects (or any other Holoviews object really). I can easily visualize one with appropriate color scaling, and I can do a layout to get both figures with the same scaling and coloring. What if I want to do two figures (e.g. because I need them on different pages), but with the same coloring and scaling so that the figures are comparable.
If there's no way to do this automatically, is there any way to access the relevant settings and then feed them manually to the second figure?
If you're using a notebook: The %opts line magic : IPython specific syntax applied globally [string format]http://holoviews.org/user_guide/Customizing_Plots.html and I think hv.opts works globally in script.
For both backends, you can do hv.renderer('bokeh').get_plot(your_element_variable).state (or replace bokeh with matplotlib) and get the original bokeh/matplotlib items.
Then you can use matplotlib's plt.getp() or bokeh's attribute calling (as I've done here https://github.com/ahuang11/holoext/blob/master/holoext/xbokeh.py#L501-L508) to get the base item's color/font/labels/etc.
Can anybody know how to split an STL into surfaces in VTK? Or how to do it in Paraview?
Depends on how you want to split it. If you want to split it into grouped surfaces, use vtkPolyDataNormals with SplittingOn, and use SetFeatureAngle to decide what angle to split at. Then, you can use vtkPolyDataConnectivityFilter to get each split piece in a loop.
In ParaView :
Open ParaView
File -> Open -> Select your STL file, Apply
You obtain a single vtkPolyData object, you can then use ParaView for any splliting you may want to do.
In VTK :
vtkNew<vtkSTLReader> reader;
reader->SetFileName("/path/to/your/file.stl");
reader->Update()
You can the use reader output and show it or split it to your needs using VTK filters.
I'm kind of new to all the PDF crop/bleed/trim technicalities... but what I have is business cards in PDF format of about 9 x 5 cm. I just want to add the bleed and crop marks, or if not bleed margins then at least just the crop marks, at specified mm from the edges.
Is there anyway I can do this programmatically in linux? Like maybe by using pdftk or ghostscript or imagemagick or some php library? By crop marks I mean the little lines at each corner of the document. Is it possible to maybe just draw lines on the PDF using imagemagick, if there's no direct function available to do this? Please keep in mind I want to add the crop marks to existing cards, so I'm not making cards from scratch. I'm not sure but this might be called "imposition".
Can it be done easily via a desktop application?
try with latex
create file foobar-crop.tex
\documentclass{article}
\usepackage{pdfpages}
\usepackage[paperwidth=9cm,paperheight=5cm]{geometry}
\usepackage[cam,a4,center,pdftex]{crop}
\begin{document}
\includepdf[pages=-]{foobar.pdf}
\end{document}
compiling with
$ pdflatex foobar-crop.tex
will get you foobar-crop.pdf.
from: http://www.thbimage.com/pdf/adding_crop_marks_to_pdf_pan_2008_10_08_21_47_33_lutrina_.html
I have a bezier path library to draw complex bezier paths without problem. Now, I need to know how to read a text or font and extract its path information to draw it as a path instead of as text.
I came across a C application, FontForge. It does exactly what I need, picks any font and extract its path information. But what I need to know is how it does it to add that feature to my drawing library.
You can use windows GDI function GetGlyphOutline.
Alternatively use BeginPath, TextOut, EndPath and GetPath. You will obtain a list of straight segments and Beziers. See this article for inspiration (a bit dated, but relevant).
I'm creating a series of plots in R (I'm using ggplot2, but that's not essential) and I want to be able to save my output so I can then edit it for furthur use, For instance, I might want to move legends about, or adjust colours etc. I have seen that ggplot2 has a save command but that seems to produce pdf's or bitmaps, neither of which are particularly editable
How do other people do this ? Any good ideas ?
Here's some sample code to produce a sample plot;
library(ggplot2)
dataframe<-data.frame(fac=factor(c(1:4)),data1=rnorm(400,100,sd=15))
dataframe$data2<-dataframe$data1*c(0.25,0.5,0.75,1)
dataframe
testplot<-qplot(x=fac, y=data2,data=dataframe, colour=fac, geom=c("boxplot", "jitter"))
testplot
Thanks
Paul.
Other editable formats:
Take a look at help(devices) for other formats which are available: these include svg, pictex and xfig, all of which are editable to greater or lesser extents.
Note that PDFs can be edited, for instance using the Omnigraffle tool available for Apple's OSX.
Other ways to record plot data:
In addition, you can record R's commands to the graphics subsystem for repeating it later - take a look at dev.copy:
Most devices (including all screen devices) have a display list
which records all of the graphics operations that occur in the
device. 'dev.copy' copies graphics contents by copying the display
list from one device to another device. Also, automatic redrawing
of graphics contents following the resizing of a device depends on
the contents of the display list.
Using Rscript to create a repeatable, editable plot:
I typically take a third strategy, which is to copy my R session into an Rscript file, which I can run repeatedly and tweak the plotting commands until it does what I want:
#!/usr/bin/Rscript
x = 1:10
pdf("myplot.pdf", height=0, width=0, paper="a4")
plot(x)
dev.off();
With ggplot and lattice, you can use save to save the plot object to disk and then load it later and modify it. For example:
save(testplot, file = "test-plot.rdata")
# Time passes and you start a new R session
load("test-plot.rdata")
testplot + opts(legend.position = "none")
testplot + geom_point()
Thanks for the answers, I've played around with this, and after some help from my friend Google I found the Cairo package, which allows creation of svg files, I can then edit these in Inkscape.
library(Cairo)
Cairo(600,600,file="testplot.svg",type="svg",bg="transparent",pointsize=8, units="px",dpi=400)
testplot
dev.off()
Cairo(1200,1200,file="testplot12200.png",type="png",bg="transparent",pointsize=12, units="px",dpi=200)
testplot
dev.off()
Now I just have to play around with the various settings to get my plot as good as it can be before writing the file.
right click the mouse on the output plot
Copy as metafile
then save plot into a word document (right click to edit picture to covert to the plot to Microsoft Office drawing Object)