# Differences

This shows you the differences between two versions of the page.

 graphics [2018/03/01 10:20]qcbs graphics [2018/10/29 13:35] (current)qcbs [Exercise 7 - GIFs!] 2018/10/29 13:35 qcbs [Exercise 7 - GIFs!] 2018/10/26 11:39 qcbs [Exercize 5 - Using the svglite package.] 2018/10/26 11:39 qcbs [Exercise 5 - Editing R figures in Inkscape with svglite package.] 2018/10/26 10:38 qcbs [Exercice 6 - Infographique!] 2018/10/26 10:17 qcbs [Exercise 6 - GIFs!] 2018/10/26 10:16 qcbs [Exercice 6 - Infographique!] 2018/10/26 10:16 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2018/10/26 10:16 qcbs [Exercise 5] 2018/10/26 10:14 qcbs [Exercise 5] 2018/10/26 10:13 qcbs [Exercise 6] 2018/10/26 10:13 qcbs [Exercise 4 - GIFs!] 2018/10/26 10:11 qcbs [Introduction to graphic design and image manipulation with open source tools] 2018/03/01 10:20 qcbs 2018/02/27 11:26 qcbs 2017/10/30 16:41 qcbs [Exercise 6] 2017/10/30 16:39 qcbs [Exercise 5] 2017/10/30 16:36 qcbs [Exercise 5] 2017/10/30 16:34 qcbs [Exercise 5] 2017/10/27 16:53 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2017/10/27 16:53 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2017/10/27 16:46 qcbs [Exercise 6] 2017/10/26 16:27 qcbs [Introduction to graphic design and image manipulation with open source tools] 2017/10/26 11:57 qcbs [Exercise 1 - Basic image cropping, rotation and resizing.] 2017/10/25 16:54 qcbs [The R Magick package] 2017/10/25 16:54 qcbs [The R Magick package] 2017/10/25 15:36 qcbs [The R ImageMagick package] 2017/10/25 15:36 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:35 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:35 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:30 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:29 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:12 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:11 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:10 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:10 qcbs [Exercise 7] 2017/10/25 14:44 qcbs [Exercise 4 - GIFs!] 2017/10/25 14:39 qcbs [Exercise 3 - Layer masks.] 2017/10/25 14:28 qcbs [Exercise 2 - Layers, cropping and manipulation of colors.] 2018/10/29 13:35 qcbs [Exercise 7 - GIFs!] 2018/10/26 11:39 qcbs [Exercize 5 - Using the svglite package.] 2018/10/26 11:39 qcbs [Exercise 5 - Editing R figures in Inkscape with svglite package.] 2018/10/26 10:38 qcbs [Exercice 6 - Infographique!] 2018/10/26 10:17 qcbs [Exercise 6 - GIFs!] 2018/10/26 10:16 qcbs [Exercice 6 - Infographique!] 2018/10/26 10:16 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2018/10/26 10:16 qcbs [Exercise 5] 2018/10/26 10:14 qcbs [Exercise 5] 2018/10/26 10:13 qcbs [Exercise 6] 2018/10/26 10:13 qcbs [Exercise 4 - GIFs!] 2018/10/26 10:11 qcbs [Introduction to graphic design and image manipulation with open source tools] 2018/03/01 10:20 qcbs 2018/02/27 11:26 qcbs 2017/10/30 16:41 qcbs [Exercise 6] 2017/10/30 16:39 qcbs [Exercise 5] 2017/10/30 16:36 qcbs [Exercise 5] 2017/10/30 16:34 qcbs [Exercise 5] 2017/10/27 16:53 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2017/10/27 16:53 qcbs [Exercise 7 - Editing R figures in Inkscape with svglite package.] 2017/10/27 16:46 qcbs [Exercise 6] 2017/10/26 16:27 qcbs [Introduction to graphic design and image manipulation with open source tools] 2017/10/26 11:57 qcbs [Exercise 1 - Basic image cropping, rotation and resizing.] 2017/10/25 16:54 qcbs [The R Magick package] 2017/10/25 16:54 qcbs [The R Magick package] 2017/10/25 15:36 qcbs [The R ImageMagick package] 2017/10/25 15:36 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:35 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:35 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:30 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:29 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:12 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:11 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:10 qcbs [Exercise 8 - Using the R ImageMagick package] 2017/10/25 15:10 qcbs [Exercise 7] 2017/10/25 14:44 qcbs [Exercise 4 - GIFs!] 2017/10/25 14:39 qcbs [Exercise 3 - Layer masks.] 2017/10/25 14:28 qcbs [Exercise 2 - Layers, cropping and manipulation of colors.] 2017/10/25 14:23 qcbs [Exercise 1 - Basic image cropping, rotation and resizing.] 2017/10/25 13:04 qcbs [Exercise 5] 2017/10/25 11:57 qcbs [Exercise 5] 2017/10/24 15:49 qcbs [Exercise 3 - Layer masks.] 2017/10/24 15:38 qcbs [GIMP] 2017/10/24 15:37 qcbs [Inkscape] 2017/10/24 15:37 qcbs [Inkscape] 2017/10/24 15:27 qcbs [Introduction to graphic design and image manipulation with open source tools] 2017/10/24 14:45 qcbs [Exercise 3 - Layer masks.] 2017/10/24 14:19 qcbs [Exercise 2 - Layers, cropping and manipulation of colors.] 2017/10/23 17:11 qcbs [Exercise 1 - Basic image cropping, rotation and resizing.] 2017/10/23 15:41 qcbs [Exercise X] 2017/10/23 15:41 qcbs [Exercise X] Line 3: Line 3: Offered by Guillaume Larocque, Quebec Centre for Biodiversity Science. ​ Offered by Guillaume Larocque, Quebec Centre for Biodiversity Science. ​ - October ​31, 2017. McGill University. ​ + October ​30, 2018. McGill University. ​ [[https://​prezi.com/​view/​P9qA6oN11cCAwjay2Hml/​|Link to Prezi presentation.]] [[https://​prezi.com/​view/​P9qA6oN11cCAwjay2Hml/​|Link to Prezi presentation.]] Line 58: Line 58: - Your image should now be blurry on the top and bottom and should have the tilt-shift look. What happens if you now make the mask from step 1 visible? What if you change their order? ​ - Your image should now be blurry on the top and bottom and should have the tilt-shift look. What happens if you now make the mask from step 1 visible? What if you change their order? ​ - ==== Exercise 4 - GIFs! ==== - You will be making a GIF animation that highlights how cool your research is! - - * Find some photos or graphs from your research that you want to highlight. ​ - * Click on File>New and select a 640x480 document with a White background. ​ - * Open the content you want to put in the animation in GIMP and copy it as new layers using Edit>​Paste as...>​New layer. Resize the content to fit into the page using the Scale Tool. - * Reorder the layers, knowing that the bottom layer will be played first and the top layer last. - * Change the name of each layer to designate the associated content. After the name of the layer add (500ms) to get something like: "First photo(500ms)"​. The number in parenthesis is the duration of this slide in the GIF animation. ​ - * For slides with text, click on the Text tool and and choose the font and font size from the Tool options before adding the text. When you are done placing and resizing the text, add (500ms) to the name of the text layer. ​ - * To give a background to your text, first choose a foreground color by clicking on the Foreground and Background Color icon. Then, add an empty layer to the bottom of the text (by clicking the Create a new layer icon {{::​add_layer_icon.png?​nolink|}}) that has that foreground color. When satisfied with both the text and the background, right click on the text layer and choose Merge Down. The text is now fused with the background and you can't remove it. - * You can test your animation by clicking on Filters>​Animate>​Playback. ​ - * When you are happy with your work, choose File>​Export as>GIF Image, and then click on As animation, leaving the other options unmodified. If it asks if you want to crop, click yes. - * You can now open your animation in a web browser! ​ ===== Inkscape ===== ===== Inkscape ===== To install Inkscape, go to [[https://​inkscape.org/​en/​release/​0.92.2/​|this site]] and download the version for your platform. If you are on Mac OSX, carefully read the extra steps needed. ​ To install Inkscape, go to [[https://​inkscape.org/​en/​release/​0.92.2/​|this site]] and download the version for your platform. If you are on Mac OSX, carefully read the extra steps needed. ​ - ==== Exercise ​5 ==== + ==== Exercise ​4 ==== Line 98: Line 85: - Export your logo as a PNG image by clicking on File>​Export PNG image. Click on Export area "​Page"​ and then select a size of 500x500px. ​ - Export your logo as a PNG image by clicking on File>​Export PNG image. Click on Export area "​Page"​ and then select a size of 500x500px. ​ - ==== Exercise 6 ==== + ==== Exercize 5 - Using the svglite package.==== - You are asked to propose a "​badge"​ for the QCBS that is inspired by the elements of the current logo. You have to use one of the three organisms present on the QCBS logo and a circular photo cutout, with the QCBS name in a circle around the photo. The final product could look something like this (or not). + If you are unable ​to do this exercize, you can download ​the {{ ::fig1.svg |SVG File here}} - {{::qcbs_relogo_ex.png?​direct&​250|}} + + - Install the svglite package and the spocc package<​file rsplus>​install.packages('​svglite'​) + install.packages('​spocc'​)​ + - Load the library. ​library(svglite)​ + - Execute the following code to create a pie chart, or adapt the code for another species or to use your own data. + df <- occ(query = 'Puma concolor',​ from = '​gbif',​limit=10000) + country_count=as.data.frame(table(df$gbif$data$Puma_concolor$country),​stringsAsFactors=FALSE) + country_count<​-country_count[order(country_count$Freq),​] + country_count<​-rbind(country_count[country_count$Freq>​50,​],​data.frame(Var1='​Other countries',​Freq=sum(country_count[country_count$Freq<​=50,'​Freq'​]))) - - Create a new Inkscape document and make it 200mmx200mm. + svglite("​fig1.svg"​) - - Go to [[http://​unsplash.com|Unsplash]] and download a photo that you think would be appropriate for the background of the badge. You can search by keyword ​(e.g. "​texture"​), click on the image you like and then click on download. + pie(country_count$Freq,​labels=country_countVar1) - - Resize the image to 800px wide in GIMP. + dev.off() - - Copy the image from GIMP to Inkscape using copy-paste. Put it on the side of your page. + ​ - - Create a circle that fills about 75% of the page. Make the width and height of the circle identical ​in the top menu. Center align the circle on the page, both horizontally and vertically. Make two copies of this circle and keep them on the side. We'll need them later. + - You should now have a this file as an SVG on your computer. If you are unsure where it is, type getwd() to identify your working folder. - - Resize your photo and put it under the circle so that the part of the photo that you want to keep is inside ​the circle. If the photo is on top of the circle, select the photo and move it below (PAGE DOWN). + - You can now open this graphic and modify it in Inkscape. - - Select both the circle and the image (press SHIFT while clicking on both), and click on Object>​Clip>​Set. Now the photo should be in the form of a circle. + - If you are curious, your can open this SVG file in Notepad or TextEdit ​to check the structure ​of the SVG/XML file. You could modify ​the file in text form if you wanted. - - Download this {{::​logo1_trans_no_text.png?​linkonly|png ​file}} containing the QCBS logo in bitmap/​raster ​format. Open it in Inkscape. ​ + - Note that the text created with svglite has a fixed width (textLength ​is specified in the xml text tag. So, if you increase ​the size of the font, it will become higher but not wider. To fix this problem, open the XML Editor ​(Edit>XML Editor) and clear the textLength section for text objects. You could also make this change by editing ​the SVG in a text editor. - - We will now turn this image into vector format. ​Click on the QCBS logo and select Path>Trace bitmap. Select single scan and Brightness cutoff. Then click on OK. + - Note that you could also save your file in pdf format ​and open it in Inkscape ​as a PDF. It will still be a vector ​file, but it may be easier to use in some cases than the SVG format. ​ - - There is now a vector version of the logo on top the original one. Click on it and move it to the side. + pdf("​fig1.pdf"​) - - Click on the new vector logo, and select Path>Break apart. This will separate the elements that don't touch each other. + pie(country_countFreq,​labels=country_count\$Var1) - - Choose ​which of the owl, the butterfly or the iris you want to isolate. If necessary, remove ​the design elements that protrude out of the organism by double clicking on it and deleting ​the associated nodes (DEL key after clicking on them). You might need to adjust ​the curvature handles. + dev.off() - - Note that the white elements that were inside ​the black parts have been made black. To make them "​holes"​ in the object, select the entire region around the organism ​and click on Path>​Combine. This will make the entire selection white. Make it black so that you can see it. Select ​the grouped organism ​and copy-paste it to the Inkscape page containing ​the badge. + ​ - - Resize and move the organism to the approximate center ​of the badge (based on visual perception rather than absolute center). Make it white, or another color of your choice. + ==== Exercise 6 - Infographic! ==== - - Click on the circle you copied earlier and make the stroke width around 10px and make the stroke dark grey, or what you like. Make the Fill empty (none). Move it on top of the other circle. + - Open the graphic created in step 7 in Inkscape. - - Click on the Create text objects icon (letter A) and click somewhere beside ​the page. Choose a font size of 25 in the top menu bar. Type in the name of the QCBS in full in French ​and English. + - Resize ​the document in File>Document properties to 240x160mm. - - Select both the the text and the circle that you (should) have left on the side. Click on Text>Put on path. The text should now be wrapped in a circle. Adjust ​the font size of the text and place it around the badge. Resize as necessary. Note that if you want the bottom portion ​to be upside-up, you need to create two arcs, one for the top (French) ​and one for the bottom (English), ​and put the text in each language on around the circle individually. + - Choose ​a color gradient. To facilitate this task, you can select from the color palette at the bottom of the screen. Next, click on the sectors ​of the diagram to change the colors ​and make a gradient from dark for the larger sectors ​to lighter colors for the smaller sectors. - - Click on the organism, go to Filters>Shadow and glow>Drop Shadow. Change Horizontal and vertical offsets to 3px and the Blur Color>​Alpha channel of the shadow ​to 200 (mostly opaque). + - Choose a contrasting dark color for the background of the infographic. Next, create a rectangle that is slightly larger than the page, and specify a background color (Fill) for it. You can use a slight color gradient for the background. To do so, in the Fill and Stroke section, you click on the Gradients option, click on the square hook at the bottom ​of the rectangle, specify a color for that, then click on the circular hook and choose ​another color for that. - - If you want to add a little "​glossy"​ effect, you can create white semi-transparent semi-circular shapes ​on the top and the bottom of the circle (see example badge above). First, start by creating a square, convert to a path, make it into the shape you want, adjust the position, size and transparency, and move above the photo, but below the other shapes. Repeat for the bottom portion. + - You can change ​the size, the color and the position of the labels for the sections ​(country names). - - Adjust other elements to your liking. You have a badge! ​ + - Click on the Create ​and edit text objects icon, and put a title for the infographic. + - To add a small paragraph of text, click/drag to delineate where the section of text will be. This way, lines of text will wrap within that section. + - Choose a photo that you want to put at the centre ​of the diagram on EOL (http://eol.org) by searching with the name of the species. Save this photo to your computer ​and import in Inkscape with File>​Import. + - Resize approximately ​the image and click on the Create circles, ellipses and arcs icon. Click-drag on the photo to delineate the part of the photo that you want to put in the circle. You can put the circle semi-transparent (Fill, change Opacity) ​to make this easier. Then, select ​the photo and the circle by clicking ​and holding ​the SHIFT key. Click on Object>Clip>Set. This should crop the photo to a circle. You can release ​the clip at any time to undo this operation and get the complete photo back. + - Download ​a silhouette of your animal, or this {{ ::​cougar_silhouette.png?​linkonly |Cougar silhouette}} and open it in Inkscape as a separate file. Click on the silhouette ​and Path>​Vectorize bitmap. Choose Colors, specify 2 passes, and click on OK. You can then select the silhouette in vector format ​by clicking on it and copy-paste it on your infographic. Now, position ​it and choose a color. + - You can experiment by adding drop shadows to certain elements. To do so, select ​and element and click on Filters>​Shadows and Glows>​Drop shadow. + - Export ​your infographic in PNG format. + - Here is an example of a {{::​cougar_infographique.png?​linkonly|completed infographic}}. ​ + + ==== Exercise 7 - GIFs! ==== + + You will be making a GIF animation that highlights how cool your research is! + + * Find some photos or graphs from your research that you want to highlight, or use the infographic you created above. ​ + * In GIMP, click on File>New and select a 640x480 document with a White background. ​ + * Open the content you want to put in the animation in GIMP and copy it as new layers using Edit>​Paste as...>​New layer. Resize the content to fit into the page using the Scale Tool. + * Reorder the layers, knowing that the bottom layer will be played first and the top layer last. + * Change the name of each layer to designate the associated content. After the name of the layer add (500ms) to get something like: "First photo(500ms)"​. The number in parenthesis is the duration of this slide in the GIF animation. ​ + * For slides with text, click on the Text tool and choose the font and font size from the Tool options before adding the text. When you are done placing and resizing the text, add (500ms) to the name of the text layer. ​ + * To give a background to your text, first choose a foreground color by clicking on the Foreground and Background Color icon. Then, add an empty layer to the bottom of the text (by clicking the Create a new layer icon {{::​add_layer_icon.png?​nolink|}}) that has that foreground color. When satisfied with both the text and the background, right click on the text layer and choose Merge Down. The text is now fused with the background and you can't remove it. + * You can test your animation by clicking on Filters>​Animate>​Playback. ​ + * When you are happy with your work, choose File>​Export as>GIF Image, and then click on As animation, leaving the other options unmodified. If it asks if you want to crop, click yes. + * You can now open your animation in a web browser! ​ - ==== Exercise 7 - Editing R figures in Inkscape with svglite package.==== - - - Install the svglite package. ​install.packages('​svglite'​)​ - - Load the library. ​library(svglite)​ - - Run the following code to produce a graphic, or adapt this code with one of your own figures from R. - svglite("​fig1.svg"​) - tot <- colMeans(VADeaths) - text(mp, tot + 3, format(tot),​ xpd = TRUE, col = "​blue"​) - barplot(VADeaths,​ beside = TRUE, - col = c("​lightblue",​ "​mistyrose",​ "​lightcyan",​ - "​lavender",​ "​cornsilk"​),​ - legend = rownames(VADeaths),​ ylim = c(0, 100)) - title(main = "Death Rates in Virginia",​ font.main = 4) - dev.off() - ​ - - You should now have the figure in a SVG file in your current working directory. If you are not sure where that is, type getwd(); - - For curiosity, you can open the SVG file in Notepad or TextEdit to see what the structure of the file is like. You could edit the file from there if you wanted! - - Open this image in Inkscape by clicking File>​Open and then selecting the SVG file. - - Change the colors of the bars to make them gradients that start darker at the bottom and become lighter at the top. To do so, click on the bar that you want to adjust, click on Fill and the Linear Gradient icon. Adjust the color of the gradient ends and the orientation by interacting with the gradient handles. When you are happy of one bar with a given gradien, select that bar click on Edit Copy/​CTRL-C,​ select the other bars of the same color and click on Edit>​Paste Style. All bars should now have the same gradient. Repeat with other bars to change the colors as you desire. ​ - - Make the legend bigger by selecting all the elements of the legend (click-drag),​ pressing CTRL-G to make it a group and then resizing it with the resize handles to make it bigger. ​ - - Note that the text in svglite comes with the textLength property set to a given value. So, if you try to change the font size of the text, it will only make the text '​higher'​ and not wider. To fix this, open Edit>XML Editor, and empty out the textLength property for the text objects. Note that you can also remove it from the SVG file in a text editor. ​ ===== The R Magick package ===== ===== The R Magick package =====