Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

1- I have the following curve which is the result of evaluation of some calculation. the curve should have value at zero. but in the plotting I can see there is a gap between the y-axis and the starting of the curve. how I can make the curve to reach y-axis. I already have a value of BER when x is zero, why it is not appear in the plot?

2- How I can make the value of y-axis to be like this: 10^-5, 10^-4, 10^-3, 10^-2, ... ? I mean not be like this 0.001, 0.01, ...

3- how to make the label axis position be in the centre of the axis not at the end?

4- how to show the grid in the plot background?

Thanks

Ploting BER vs SNR

Edit:

here is a sample values of abep for the (0 to 40) SNR:

{0.263671, 0.223935, 0.186064, 0.151073, 0.119779, 0.092718, 0.0700926, 0.0517928,
 0.0374553, 0.0265532, 0.0184883, 0.0126685, 0.00856004, 0.0057148, 0.00377648, 
 0.00247428, 0.00160959, 0.00104095, 0.000669973, 0.000429521, 0.000274496, 
 0.000174975, 0.000111307, 0.0000706891, 0.0000448341, 0.0000284057, 0.0000179819, 
 0.0000113756, 7.19252*10^-6, 4.5457*10^-6, 2.87193*10^-6, 1.81396*10^-6, 
 1.14549*10^-6, 7.23233*10^-7, 4.56569*10^-7, 2.88196*10^-7, 1.819*10^-7, 
 1.14801*10^-7, 7.24499*10^-8, 4.57204*10^-8, 2.88515*10^-8}
share|improve this question
2  
Ad 1. Please show some minimal working example. Ad 1.1 Do not post pictures of the code but the code. Ad 2. That question was asked here already (help me find it) Ad 3. Use restricted Frame with FrameLabels instead of Axes. Ad 4. GridLines Ad 5. One question = One question(or couple closely related) –  Kuba Sep 12 '13 at 9:49
    
If abep is a list of values not coordinates ListPlot will count them strarting from 1. Use DataRange to deal with that. Just a guess I don't know what do you have :) –  Kuba Sep 12 '13 at 10:00
    
here is a sample values of abep for the (0 to 40) SNR: {0.263671, 0.223935, 0.186064, 0.151073, 0.119779, 0.092718, \ 0.0700926, 0.0517928, 0.0374553, 0.0265532, 0.0184883, 0.0126685, \ 0.00856004, 0.0057148, 0.00377648, 0.00247428, 0.00160959, \ 0.00104095, 0.000669973, 0.000429521, 0.000274496, 0.000174975, \ 0.000111307, 0.0000706891, 0.0000448341, 0.0000284057, 0.0000179819, \ 0.0000113756, 7.19252*10^-6, 4.5457*10^-6, 2.87193*10^-6, 1.81396*10^-6, 1.14549*10^-6, 7.23233*10^-7, 4.56569*10^-7, 2.88196*10^-7, 1.819*10^-7, 1.14801*10^-7, 7.24499*10^-8, 4.57204*10^-8, 2.88515*10^-8} –  barznjy Sep 12 '13 at 11:45
add comment

2 Answers 2

up vote 4 down vote accepted

Here is my poor man's solution :)

data = {# - 1, abep[[#]]} & /@ Range@Length@abep; 

ListLogPlot[data,
 PlotRange -> {{0, 40}, {10^-5, 10}},
 Joined -> True,
 FrameLabel -> {{ANR, None}, {SNR, "my nice looking plot"}},
 LabelStyle -> Directive[Blue, Bold],
 RotateLabel -> False,
 Frame -> True,
 GridLines -> Automatic,
 GridLinesStyle -> LightGray,
 FrameTicks ->{{Table[{10^k, Superscript[10, k]}, {k, -5, 1}],None},{Automatic,None}},
 BaseStyle -> FontFamily -> "Times"]

Mathematica graphics

Since ListLogPlot assumes data corresponds to coordinates 1,2,3 when given in the form you had it in, which is {y1,y2,...}, then one can use the second form, which is {x1,y1} to force the x1 to be at zero.

Updated to use the trick shown in How to express ticks in scientific form? (thanks to link given above by Kuba), this seems the easiest way to make the log ticks).

share|improve this answer
add comment

The following should answer all your questions

data = Table[10^k, {k, .5, -5.4, -0.2}];

This will anchor the first data point to x = 0 in the plot.

pts = Transpose[{Range[0, -1 + Length@data], data}];

This will set the positions of the horizontal grid lines and the y-axis ticks.

hlines = Table[10^k, {k, -5., 1., 1.}];

This will generate the list of y-ticks in the requested format.

yticks = 
  {#, NumberForm[#, 
        NumberFormat -> (Superscript[10, #3] &), 
        ExponentFunction -> (#1 &)]} & 
  /@ hlines;

And now the plot:

Labeled[
  ListLogPlot[pts,
    PlotRange -> {{0., 40.}, {10.^-5, 10.^1}},
    GridLines -> {Automatic, hlines},
    Ticks -> {Automatic, yticks}],
  Style[#, Bold, Blue] & /@ {"SNR", "BER"},
  {Bottom, Left}]

plot.png

Finally, let me say that I had no trouble finding all the information needed to make this plot in the Mathematica Documentation Center. I will admit the code for getting the y-axis tick labels in the requested display form may be a bit opaque. There might be more straight forward way of making those labels but it eludes me.

Edit

Kuba pointed out a link to an answer by David Carraher which gives the more straight forward way of making those y-axis labels that I thought might exist.

yticks = Table[{10^k, Superscript[10, k]}, {k, -5, 1}];
share|improve this answer
1  
About ticks notation –  Kuba Sep 12 '13 at 12:58
    
@Kuba. Yeah, that's better. –  m_goldberg Sep 12 '13 at 12:59
    
Thank you everyone. –  barznjy Sep 12 '13 at 17:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.