Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make dashed / dotted / dash-dotted line in octave?

Tags:

plot

octave

I'd like to create monochrome diagram/graph in octave using plot command. That is why I'd like make different lines of graphs with using line style, for example dashed/dotted/dash-dotted styles. Standard plot suggests several styles for line, but none of them looks like listed variants.


EDIT-1: Standard plot styles are inapplicable for my case: such styles as ":", "-.", "--" don't work, octave draws solid lines in any case. Furthermore, diamonds and squares (d and s options) are ugly and disproportionate big. May be it will be helpful information: I'm using Octave under Windows.


EDIT-2: For example, such command plot(A(:,1),A(:,2),"-.dk") gives me such (inapplicable !!!) figure

enter image description here


More specifically I want something like this (in part of line style) xxx

(Picture from article: McCallum and K. Nigam. 1998. A comparison of event models for Naive Bayes text classification. In Proceedings of AAAI-98 Workshop on Learning for Text Categorization)

like image 270
Andremoniy Avatar asked Dec 27 '22 11:12

Andremoniy


2 Answers

These can be set with the FMT argument of plot. Basically, these seem to be your options (see the manual entrey on line styles):

  • "-" solid lines
  • ":" points
  • "-."dash followed by dot
  • "--" dashed
  • "none" no line (only markers)

There is also the option "." for dots but this is for the actual data points, not the line. So to recreate your picture, something like the following should work

plot (multinominal, "-dk", "MarkerFaceColor", "k")
hold on;
plot (mv-bernoulli, ":sk", "MarkerFaceColor", "k")

The syntax may look a bit strange but here's how to read it. For -dk, - is for solid line, d for diamond shaped marker, and k for black colour (b would be for blue). On :sk, it's dotted line and square shaped marker in black colour.

See the section on the manual for advanced plotting.

EDIT: see the comments below. This may not work in very old versions of Octave.

like image 65
carandraug Avatar answered Dec 28 '22 23:12

carandraug


Well, I found a simple solution by myself (using Google ;)) For gaining monochrome diagram/graph with a different style of lines in Octave, we don't need to use plot's styles like "--" or "-." (because they do not work).

Just one thing we need is the command print. Monochrome figures can be created for example in the eps format:

print -deps "diagram.eps"

This gives me quite a nice picture:

enter image description here

like image 32
Andremoniy Avatar answered Dec 29 '22 00:12

Andremoniy