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.

In Mathematica, customizing Sections, Subsections, Titles and so on, can be done with Format > Style > .... Changing the background color of a style is one of the things you can do. Here is an example where I have colored the background orange:

enter image description here

But I want to change the background to show a color gradient. I mean, instead of having the same orange in all of the background, there should be a gradient so the orange fades from top to bottom. Gradient styles will be found in Palettes > Color Schemes. But I can't get it to work for changing the color of a cell background.

share|improve this question
1  
I don't know if it's possible to specify a gradient background (it may be in recent versions, but I don't think it is in v7 -- which I use). Nevertheless you can specify a bitmap fill for full control: (6318) –  Mr.Wizard Jun 4 at 10:45
2  
    
@belisarius Crikey! =:-O –  Mr.Wizard Jun 4 at 12:56
    
@goldberg, thank you for your editing. –  mostafa Jun 4 at 13:55

1 Answer 1

up vote 3 down vote accepted

I'm not sure how exactly to integrate this with a stylesheet background, but here is a way to achieve gradients using Graphics:

Overlay@{
  Graphics[
   Raster@{List@@@Table[Blend["AvocadoColors",i],{i,0,1,.005}]},
   AspectRatio->1/2,
   ImageSize->Full],
  Graphics[
   Text@Style["Gradient!",FontSize->Scaled@.2],
   AspectRatio->1/2,
   ImageSize->Full]}

enter image description here

EDIT

I stumbled on a different way to do this that would be easier for simple layouts (tidied up with kguler's suggestion):

Graphics[{
  Polygon[
    {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
    VertexColors -> {Yellow, Yellow, Green, Green}], 
  Text[
    Style["Gradient!", FontSize -> Scaled@.2], 
    Scaled[{.5, .5}]]}, ImageSize -> Full, AspectRatio -> 1/2]

enter image description here

share|improve this answer
    
You can do without Overlay putting Text[..] and Polygon[...] in a single Graphics: Graphics[{Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexColors -> {Yellow, Yellow, Green, Green}], Text[Style["Gradient!", FontSize -> Scaled@.2], Scaled[{.5, .5}]]}, ImageSize -> Full, AspectRatio -> 1/2] –  kguler Jun 6 at 19:28
    
@kguler I was just exercising my fingers :P –  mfvonh Jun 6 at 20:07

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.