Thursday, April 28, 2016

Saving Google Docs/Sheets charts as PDF

Google docs natively supports saving charts as PNG. But if you want to generate high quality images, such as PDF, you can follow the steps below.

1. Go to the Google Spreadsheet page with the chart
2. Open Chrome Developer Tools (from Chrome hamburger menu -- 3 lines menu -- on the top right)
3. Select the "Elements" tab and click on the button "Select an element to inspect it" present on the top left.
4. Click in the chart area.
5. Look at the tree and find the beginning of svg description (e.g. <svg...).
6. Right click on the SVG line and select "Copy as HTML"
7. Paste it to your favorite editor, and save as "MyChart.svg"

You can use image processing tools, such as Photoshop or GIMP to export the files as PDF.

References:
1. http://www.osmanoglu.org/computing/89-how-to-export-google-spreadsheet-charts-as-svg

Tuesday, November 24, 2015

R: MIssing legend when using scale_fill_manual

When configuring ggplot using scale_fill_manual in R, sometimes the legend might not be displayed. This happens when we specify 'breaks' property within the scale_fill_manual command, and the values we supply don't correspond to the factor levels we use in fill.

For instance, assume we have a data frame with columns 'X', 'Y', and 'Type', where 'Type' contains values 'A' and 'B'. In the below ggplot/ggplot2 command, breaks argument cannot contain a list of strings which do not map to factor levels in column 'Type':
ggplot2(data=df, aes(x=X, y=Y, fill=Type)) + 
scale_fill_manual(values=c("black","red", name="Type", breaks=c("A","B"), labels=c("Type-A","Type-B"))

Instead, we need to specify the breaks as:
ggplot2(data=df, aes(x=X, y=Y, fill=Type)) + 
scale_fill_manual(values=c("black","red", name="Type", breaks=levels(factor(df$Type)), labels=c("Type-A","Type-B"))

Or as below, if we are sure of the factor ordering:
ggplot2(data=df, aes(x=X, y=Y, fill=Type)) + 
scale_fill_manual(values=c("black","red", name="Type", labels=c("Type-A","Type-B"))

References:
1. http://stackoverflow.com/questions/14546858/missing-legend-when-combining-scale-fill-manual-and-scale-x-discrete-in-bar-char

Wednesday, September 23, 2015

Windows 7 Safe mode - Starting "Run Installer" and "Print Spooler" services

Windows Installer will not work under Safe Mode, this means that programs cannot be installed or uninstalled in safe mode without giving a specific command using msiexec in command prompt.

To make Windows Installer work under safe mode, you need to create a registry entry for every type of safe mode you are logged in to.

Run these commands from command line:
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer" /VE /T REG_SZ /F /D "Service"

net start msiserver 


To Start Print Spooler
Method-1:
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Spooler /VE /T REG_SZ /F /D Service

Net Start Spooler

Method-2:
Run Command prompt in administrator mode (right click and press "Run as Administrator"), and then run these commands.
Net stop spooler
sc config spooler depend= RPCSS
Net start spooler
exit

Reference:
1. http://www.symantec.com/connect/blogs/windows-installer-safe-mode
2. https://forums.techguy.org/threads/solved-enabling-print-spooler-in-safe-mode.1056317/
3. http://www.techsupportall.com/solved-print-spooler-error-1068-the-dependency-service-or-group-failed-to-start/

Saturday, December 27, 2014

Activate/Enable Sound in Windows 7 Safemode

Here are the sequence of steps. For full steps refer the reference [1].

  1. Run (Win key+R key) regedit
  2. Press Ctrl+F
    1. Make sure "Keys", "Values", and "Data" are all selected
    2. Type in Sound, video and game controllers
    3. Click [Find Next]
  3. Take note of the branch address in the status bar at the bottom (it will be something like HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E96C-E325-11CE-BFC1-09002BE10318})
  4. Copy the device-driver GUID (the long numeric part between braces) and paste it somewhere like Notepad
  5. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network
  6. Create a new key (right-click, select New → Key)
    1. Copy the GUID you saved and paste it into the key name
    2. Edit the (Default) value and type Sound, video and game controllers
  7. Create several new keys (under Network) called AudioEndpointBuilder, MMCSS and Audiosrv
  8. Edit the (Default) values of each of the new keys and type Service
  9. Reboot (you’ll boot into safe-mode)
  10. Open the Services snap-in (Win key+R key → services.msc)
    1. Search for "Multimedia Class Scheduler", "Windows Audio Endpoint Builder", and "Windows Audio Service services", and check if they are automatically turned on (they should be). If not start them. 
References:
1. http://superuser.com/questions/354325/how-to-enable-audio-in-safe-mode

Thursday, October 30, 2014

Latex: Underlining text along with adjacent white space

To underline text in latex we use \underline{...}.
In cases when we need to underline text and the adjoining whitespace (before and after the text), like in situations of having a filled form, we can use the \makebox command as below:

\underline{\makebox[2.5in][l]{Jane Doe}}

Reference:
1. http://www.latex-community.org/forum/viewtopic.php?f=44&t=5162