Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Axes grid line widths

Subject: Axes grid line widths

From: Oliver Woodford

Date: 22 Feb, 2011 15:46:23

Message: 1 of 7

Hi all

The following code:

>> figure;
>> plot(rand(3))
>> set(gca, 'XScale', 'Log', 'Xgrid', 'on', 'YGrid', 'on')
>> print test.pdf -dpdf

creates a plot whose horizontal grid lines are thinner than the vertical ones. Does anyone know how I can fix this?

Thanks,
Oliver

Subject: Axes grid line widths

From: Oliver Woodford

Date: 22 Feb, 2011 15:59:05

Message: 2 of 7

"Oliver Woodford" wrote:
> Hi all
>
> The following code:
>
> >> figure;
> >> plot(rand(3))
> >> set(gca, 'XScale', 'Log', 'Xgrid', 'on', 'YGrid', 'on')
> >> print test.pdf -dpdf
>
> creates a plot whose horizontal grid lines are thinner than the vertical ones. Does anyone know how I can fix this?
>
> Thanks,
> Oliver

I should clarify that the difference in width is actually in the exported pdf file. I have reported this as a bug to TMW, but I'm looking for a workround, particularly a way to set the grid line widths manually.

Subject: Axes grid line widths

From: Paulo Silva

Date: 22 Feb, 2011 16:24:04

Message: 3 of 7

"Oliver Woodford" wrote in message <ik0mg9$om9$1@fred.mathworks.com>...
> "Oliver Woodford" wrote:
> I should clarify that the difference in width is actually in the exported pdf file. I have reported this as a bug to TMW, but I'm looking for a workround, particularly a way to set the grid line widths manually.

Your code looks fine in matlab 2009b, both in the figure file and pdf file.

I also made some changes to the code so I can have a better grid, all prints correctly in my matlab.

figure;
plot(rand(3))
set(gca, 'XScale', 'Log', 'Xgrid', 'on', 'YGrid', 'on')
Xlim=get(gca,'Xlim');
Ylim=get(gca,'Ylim');
NLiX=10;
NLiY=10;
Xtick=logspace(log10(Xlim(1)),log10(Xlim(2)),NLiX);
Ytick=linspace(Ylim(1),Ylim(2),NLiY)
set(gca,'XTick',Xtick);
set(gca,'YTick',Ytick);
print test.pdf -dpdf

Subject: Axes grid line widths

From: Oliver Woodford

Date: 22 Feb, 2011 17:16:22

Message: 4 of 7

"Paulo Silva" wrote:
> Your code looks fine in matlab 2009b, both in the figure file and pdf file.
>
> I also made some changes to the code so I can have a better grid, all prints correctly in my matlab.

Strange. I see it in R2009b and R2010b (on Windows Vista 32-bit and Windows 7 64-bit respectively). Zoom into the lines, just to make sure. For me the vertical one is 40% thicker.

Funnily enough I don't have the problem when I use your regularly spaced ticks, but when I apply the technique to the graph I'm trying to export I still get the same problem.

Subject: Axes grid line widths

From: Paulo Silva

Date: 22 Feb, 2011 17:50:10

Message: 5 of 7

"Oliver Woodford" wrote in message <ik0r16$ohk$1@fred.mathworks.com>...
> "Paulo Silva" wrote:
> > Your code looks fine in matlab 2009b, both in the figure file and pdf file.
> >
> > I also made some changes to the code so I can have a better grid, all prints correctly in my matlab.
>
> Strange. I see it in R2009b and R2010b (on Windows Vista 32-bit and Windows 7 64-bit respectively). Zoom into the lines, just to make sure. For me the vertical one is 40% thicker.
>
> Funnily enough I don't have the problem when I use your regularly spaced ticks, but when I apply the technique to the graph I'm trying to export I still get the same problem.

After zooming at 800% I do see some differences, vertical line is composed of squares and horizontal ones are rectangles with their height maybe 40% of the height of the squares, at 100% zoom I couldn't see any difference at all.

Subject: Axes grid line widths

From: Oliver Woodford

Date: 23 Feb, 2011 09:43:11

Message: 6 of 7

"Oliver Woodford" wrote:
> "Oliver Woodford" wrote:
> > Hi all
> >
> > The following code:
> >
> > >> figure;
> > >> plot(rand(3))
> > >> set(gca, 'XScale', 'Log', 'Xgrid', 'on', 'YGrid', 'on')
> > >> print test.pdf -dpdf
> >
> > creates a plot whose horizontal grid lines are thinner than the vertical ones. Does anyone know how I can fix this?
> >
> > Thanks,
> > Oliver
>
> I should clarify that the difference in width is actually in the exported pdf file. I have reported this as a bug to TMW, but I'm looking for a workround, particularly a way to set the grid line widths manually.

Response from TMW:
"Searching our data base I noticed this problem is referring to a known issue already been under investigation by our developers. Unfortunately there is no fix available yet and I do not have reliable information as to when this problem will be finally resolved.

Changing this behavior requires some major changes in the underlying graphics engine, planned for one of the next release in the foreseeable future but not yet implemented in the coming release R2011a."

Subject: Axes grid line widths

From: Maridhasan

Date: 6 Sep, 2013 21:28:19

Message: 7 of 7

"Oliver Woodford" wrote in message <ik2krf$gvs$1@fred.mathworks.com>...
> "Oliver Woodford" wrote:
> > "Oliver Woodford" wrote:
> > > Hi all
> > >
> > > The following code:
> > >
> > > >> figure;
> > > >> plot(rand(3))
> > > >> set(gca, 'XScale', 'Log', 'Xgrid', 'on', 'YGrid', 'on')
> > > >> print test.pdf -dpdf
> > >
> > > creates a plot whose horizontal grid lines are thinner than the vertical ones. Does anyone know how I can fix this?
> > >
> > > Thanks,
> > > Oliver
> >
> > I should clarify that the difference in width is actually in the exported pdf file. I have reported this as a bug to TMW, but I'm looking for a workround, particularly a way to set the grid line widths manually.
>
> Response from TMW:
> "Searching our data base I noticed this problem is referring to a known issue already been under investigation by our developers. Unfortunately there is no fix available yet and I do not have reliable information as to when this problem will be finally resolved.
>
> Changing this behavior requires some major changes in the underlying graphics engine, planned for one of the next release in the foreseeable future but not yet implemented in the coming release R2011a."



Is there a solution for this now ? I am facing the same problem now. My matlab version is R2010a. Do the plots look different in a later version of the matlab?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us