PyX 0.10 is out

jwl | Programming, Plotting | Wednesday, October 10th, 2007

PyX version 0.10 is out. 3d plotting is now available. It looks ok, though there is something weird about the axis labeling in the first example. Maybe it has to be rotated more efficiently.

If you aren’t familiar with PyX, it is a plotting program with a Python interface that generates beautiful postscript or pdf plots and drawings using the TeX and LaTeX interpreters to render everything. Nothing else looks as good as TeX, so the plots from PyX look terrific.

Using LaTeX with matplotlib

jwl | LaTeX, Tips and Tricks | Tuesday, November 22nd, 2005

Matplotlib is a great program with a python interface for making 2D plots, both with python scripts and interactively. It can display plots with a variety of interfaces and also output them as eps, etc.

One nice feature is that using matplotlib.texmanager, you can have it use your native LaTeX installation interpret everything in the plot. That means everything has the same font and style as the program you are embedding it in, and you can put any kind of mathematical formula you like in there.

There is documentation on texmanager and also a little tutorial in the matplotlib examples called tex_demo.py.

Essentially, you need to set the following in your python script to activate latex interpretation:

rc('text', usetex=True)

and only export to eps or ps. Only PS and Agg are supported formats for LaTeX.

To get this working on Fedora Core 4, you need a newer version of ghostscript, downloadable in source format from here. Get ghostscript version 8.51 and the fonts tarball, and make sure you have libjpeg-devel, libpng-devel, and zlib-devel installed.

You can just do the standard for the ghostscript-8.51 source directory structure

% ./configure
% make
% make install

as root, and it will automatically install in /usr/local. I didn’t need the fonts directory at all for my tests, but it may be necessary in some situations.

Once it is installed, matplotlib should create latex files naturally, and they will look great!

UPDATE:

There is a problem with the pygtk threading code that can sometimes cause the TeX output to fail. One way around this is to use the TkAgg extension instead. Just make sure you have that option installed and edit your matplotlibrc file to use TkAgg as the default backend, and it should produce TeX output perfectly.

Maxtor One Touch II external hard drive with Linux

jwl | Linux, Tips and Tricks | Sunday, October 30th, 2005

I recently purchased a Maxtor One Touch II external hard drive to use for backups with my Linux and Windows boxes. Since I’m going to use rsync (using cygwin on Windows) for backups, I don’t care about the one touch functionality.

So I followed the excellent advice from Harish Narayanan and that seems to work fine. Thanks Harish! I’m using Fedora Core 4 with kernel version kernel-2.6.13-1.1532_FC4.

Plug in the external drive. It should be detected and mounted to /media/usbdrive automatically by the machine. You should do all this as root:

# su

You can check if it is there by running dmesg, using the tail to get only the last part. It should show up as /dev/sda1.

# dmesg | tail

You can check for this by running

# dmesg | grep Maxtor
Vendor: Maxtor Model: OneTouch II Rev: 023g

Now you want to reformat the drive, using fdisk

# /sbin/fdisk /dev/sda1

Once in fdisk, look for the partition tables by hitting ‘p’, then delete them using ‘d’, then write this to disk using ‘w’. You will get an error message, but don’t worry. The new partition will be written. Harish says to reboot at this point, but I think all you have to do is unmount the drive using

umount /media/usbdrive

and then unplug and then plug it back in.

At this point, you can then format it correctly, using

# /sbin/mkfs -t ext3 -j /dev/sda1

and wait for it to format as an ext3 filesystem.

At this point, I am stopping, because I don’t think you need to create a /mnt/external at all. You can just count on Fedora Core 4 to autodetect it as /media/usbdrive and write to that when you connect it.

In a later post, I will talk about rsync and how to use it to back up disks.

Update: actually rdiff-backup looks substantially easier to use and seems to have all the features I need. Later post will discuss that.

First post

jwl | Administration | Tuesday, November 30th, 1999

This is the first post to the blog. This blog will contain musings on a variety of topics, from book reviews to software tips and tricks. I reserve the right to edit comments or update posts, but I will always label them as such.

Powered by WordPress | Theme by Roy Tanck